Merge branch '150-not-a-comparable-type-key_hash' into 'dev'

Resolve "not a comparable type: key_hash"

Closes #150

See merge request ligolang/ligo!416
This commit is contained in:
Rémi Lesenechal 2020-02-13 16:48:24 +00:00
commit eb056364a9
3 changed files with 17 additions and 2 deletions

View File

@ -1130,3 +1130,10 @@ let%expect_test _ =
run_ligo_good [ "compile-storage" ; contract "big_map.ligo" ; "main" ; "(big_map1,unit)" ] ; run_ligo_good [ "compile-storage" ; contract "big_map.ligo" ; "main" ; "(big_map1,unit)" ] ;
[%expect {| [%expect {|
(Pair { Elt 23 0 ; Elt 42 0 } Unit) |}] (Pair { Elt 23 0 ; Elt 42 0 } Unit) |}]
let%expect_test _ =
run_ligo_good [ "compile-contract" ; contract "key_hash_comparable.ligo" ; "main" ] ;
[%expect {|
{ parameter int ;
storage (pair (map %one key_hash nat) (big_map %two key_hash bool)) ;
code { DUP ; CDR ; NIL operation ; PAIR ; DIP { DROP } } } |}]

View File

@ -16,7 +16,7 @@ module Ty = struct
let tez_k = Mutez_key None let tez_k = Mutez_key None
let int_k = Int_key None let int_k = Int_key None
let string_k = String_key None let string_k = String_key None
let _key_hash_k = Key_hash_key None let key_hash_k = Key_hash_key None
let address_k = Address_key None let address_k = Address_key None
let timestamp_k = Timestamp_key None let timestamp_k = Timestamp_key None
let bytes_k = Bytes_key None let bytes_k = Bytes_key None
@ -74,7 +74,7 @@ module Ty = struct
| TC_operation -> fail (not_comparable "operation") | TC_operation -> fail (not_comparable "operation")
| TC_signature -> fail (not_comparable "signature") | TC_signature -> fail (not_comparable "signature")
| TC_key -> fail (not_comparable "key") | TC_key -> fail (not_comparable "key")
| TC_key_hash -> fail (not_comparable "key_hash") | TC_key_hash -> return key_hash_k
| TC_chain_id -> fail (not_comparable "chain_id") | TC_chain_id -> fail (not_comparable "chain_id")
let comparable_type : type_value -> ex_comparable_ty result = fun tv -> let comparable_type : type_value -> ex_comparable_ty result = fun tv ->

View File

@ -0,0 +1,8 @@
type storage is record
one: map(key_hash, nat);
two: big_map(key_hash, bool);
end
type return is list (operation) * storage
function main (const a : int; const store : storage) : return is ((nil: list(operation)), store)