Merge branch 'fix/compare_sum_type_error' into 'dev'
[LIGO-674] rework error when comparing two sum types See merge request ligolang/ligo!682
This commit is contained in:
commit
7a2e4b35d2
@ -253,3 +253,21 @@ let%expect_test _ =
|
|||||||
* Ask a question on our Discord: https://discord.gg/9rhYaEt
|
* Ask a question on our Discord: https://discord.gg/9rhYaEt
|
||||||
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
|
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
|
||||||
* Check the changelog by running 'ligo changelog' |}]
|
* Check the changelog by running 'ligo changelog' |}]
|
||||||
|
|
||||||
|
let%expect_test _ =
|
||||||
|
run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/compare_sum_types.ligo" ; "main" ] ;
|
||||||
|
[%expect {|
|
||||||
|
ligo: error
|
||||||
|
in file "compare_sum_types.ligo", line 3, characters 9-13
|
||||||
|
Constant declaration 'main'
|
||||||
|
Those two types are not comparable:
|
||||||
|
- sum[Bar -> unit , Foo -> unit]
|
||||||
|
- sum[Bar -> unit , Foo -> unit]
|
||||||
|
|
||||||
|
|
||||||
|
If you're not sure how to fix this error, you can do one of the following:
|
||||||
|
|
||||||
|
* Visit our documentation: https://ligolang.org/docs/intro/introduction
|
||||||
|
* Ask a question on our Discord: https://discord.gg/9rhYaEt
|
||||||
|
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
|
||||||
|
* Check the changelog by running 'ligo changelog' |}]
|
@ -652,7 +652,7 @@ let rec pair_comparator : string -> typer = fun s -> typer_2 s @@ fun a b ->
|
|||||||
comparator s [a_v;b_v] None
|
comparator s [a_v;b_v] None
|
||||||
|
|
||||||
and comparator : string -> typer = fun s -> typer_2 s @@ fun a b ->
|
and comparator : string -> typer = fun s -> typer_2 s @@ fun a b ->
|
||||||
bind_or (simple_comparator s [a;b] None, pair_comparator s [a;b] None)
|
bind_or (pair_comparator s [a;b] None, simple_comparator s [a;b] None)
|
||||||
|
|
||||||
let constant_typers c : (typer , typer_error) result = match c with
|
let constant_typers c : (typer , typer_error) result = match c with
|
||||||
| C_INT -> ok @@ int ;
|
| C_INT -> ok @@ int ;
|
||||||
|
@ -447,10 +447,8 @@ let rec error_ppformat : display_format:string display_format ->
|
|||||||
Ast_typed.PP.type_expression t
|
Ast_typed.PP.type_expression t
|
||||||
| `Typer_uncomparable_types (a,b) ->
|
| `Typer_uncomparable_types (a,b) ->
|
||||||
Format.fprintf f
|
Format.fprintf f
|
||||||
"@[<hv>Those two types are not comparable:@ %a - %a@ %a - %a@]"
|
"@[<hv>Those two types are not comparable:@ - %a@ - %a@]"
|
||||||
Location.pp a.location
|
|
||||||
Ast_typed.PP.type_expression a
|
Ast_typed.PP.type_expression a
|
||||||
Location.pp b.location
|
|
||||||
Ast_typed.PP.type_expression b
|
Ast_typed.PP.type_expression b
|
||||||
| `Typer_comparator_composed a ->
|
| `Typer_comparator_composed a ->
|
||||||
Format.fprintf f
|
Format.fprintf f
|
||||||
|
4
src/test/contracts/negative/compare_sum_types.ligo
Normal file
4
src/test/contracts/negative/compare_sum_types.ligo
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
type foo is Foo | Bar
|
||||||
|
|
||||||
|
function main (const p : foo; const s : bool) : list(operation) * bool is
|
||||||
|
((nil : list (operation)), p = Foo)
|
Loading…
Reference in New Issue
Block a user