Add check for non-comparable types under `set` and `ticket`
Compare changes
@@ -1155,11 +1155,21 @@ let%expect_test _ =
Currently LIGO fails with an error on type-checking when compiling a contract that applies set
or ticket
to a non-comparable type:
$ cat not_comparable.mligo
let main ((_u, s) : (int set) set * unit) : operation list * unit = ([] : operation list), s
$ ligo compile contract not_comparable.mligo
Error(s) occurred while type checking the contract:
At (unshown) location 2, ill formed type:
1: { parameter (set (set int)) ;
2: storage unit ;
3: code { CDR ; NIL operation ; PAIR } }
At line 1 characters 17 to 25,
comparable type expected.Type set int is not comparable.
This is not a very helpful message for the user, as the locations warned in the error refer to Michelson and not to LIGO.
This MR introduces a check at 15-self_mini_c
.
$ ligo compile contract not_comparable.mligo
Error(s) occurred while type checking the contract:
At (unshown) location 2, ill formed type:
1: { parameter (set (set int)) ;
2: storage unit ;
3: code { CDR ; NIL operation ; PAIR } }
At line 1 characters 17 to 25,
comparable type expected.Type set int is not comparable.
$ ligo compile contract not_comparable.mligo
File "not_comparable.mligo", line 1, characters 21-28:
1 | let main ((_u, s) : (int set) set * unit) : operation list * unit = ([] : operation list), s
The set constructor needs a comparable type argument, but it was given a non-comparable one.
dune @fmt
to check).