Michelson: Unhelpful error message when typechecking set with uncomparable type parameter
The type argument of set
must be comparable. Keys are not comparable.
However, the error message when constructing such sets are confusing (to say the least :p)
$ tezos-client typecheck data '{}' against type '(set key)'
At (unshown) location 0, ill formed type:
1: (set key)
At line 1 characters 5 to 8,
primitive key expects 0 arguments but is given 0.
Fatal error:
ill-typed data
Trying other non-comparable values, we see two classes of error messages. First, an incorrect listing of comparable types (note that it contains key which is not comparable...):
$ tezos-client typecheck data '{}' against type '(set (big_map nat nat))'
At line 1 characters 5 to 21, invalid primitive big_map, only int, nat,
string, mutez, bool, key, key_hash or timestamp can be used here.
$ tezos-client typecheck data '{}' against type '(set chain_id)'
At line 1 characters 5 to 13, invalid primitive chain_id, only int, nat,
string, mutez, bool, key, key_hash or timestamp can be used here.
Then a more helpful error:
$ tezos-client typecheck data '{}' against type '(set (list nat))'
comparable type expected.Type list nat is not comparable.
$ tezos-client typecheck data '{}' against type '(set (map nat nat))'
comparable type expected.Type map nat nat is not comparable.
$ tezos-client typecheck data '{}' against type '(set (map operation))'
comparable type expected.Type map operation is not comparable.
$ tezos-client typecheck data '{}' against type '(set unit)'
comparable type expected.Type unit is not comparable.
The error messages should be coherent and correct. I haven't confirmed, but I think the same problem applies to the key argument to maps.