[LIGO-286] Tuple destructuring doesn't do left hand type inference in CameLIGO
This commit is contained in:
parent
56001384b5
commit
310dde6dc9
@ -564,11 +564,11 @@ and simpl_declaration : Raw.declaration -> declaration Location.wrap list result
|
||||
let%bind (v, v_type) = pattern_to_typed_var par_var in
|
||||
let%bind v_type_expression =
|
||||
match v_type with
|
||||
| Some v_type -> ok @@ (simpl_type_expression v_type)
|
||||
| None -> fail @@ wrong_pattern "typed var tuple" par_var in
|
||||
let%bind v_type_expression = v_type_expression in
|
||||
| Some v_type -> ok (to_option (simpl_type_expression v_type))
|
||||
| None -> ok None
|
||||
in
|
||||
let%bind simpl_rhs_expr = simpl_expression rhs_expr in
|
||||
ok @@ loc x @@ Declaration_constant (Var.of_name v.value, Some v_type_expression, simpl_rhs_expr) )
|
||||
ok @@ loc x @@ Declaration_constant (Var.of_name v.value, v_type_expression, simpl_rhs_expr) )
|
||||
in let%bind variables = ok @@ npseq_to_list pt.value
|
||||
in let%bind expr_bind_lst =
|
||||
match let_rhs with
|
||||
|
11
src/test/contracts/type_tuple_destruct.mligo
Normal file
11
src/test/contracts/type_tuple_destruct.mligo
Normal file
@ -0,0 +1,11 @@
|
||||
type foobar = int * int
|
||||
let test_t: foobar = 10, 25
|
||||
let foo, bar = test_t
|
||||
|
||||
let type_tuple_d (p: unit) = foo + bar
|
||||
|
||||
type complex = string * int * string * nat
|
||||
let test_t_2 = "hello", 10, "world", 50n
|
||||
let hello, ten, world, fifty_n = test_t_2
|
||||
|
||||
let type_tuple_d_2 (p: unit) = hello ^ world
|
@ -1765,6 +1765,12 @@ let key_hash () : unit result =
|
||||
let%bind () = expect_eq program "check_hash_key" make_input make_expected in
|
||||
ok ()
|
||||
|
||||
let type_tuple_destruct () : unit result =
|
||||
let%bind program = mtype_file "./contracts/type_tuple_destruct.mligo" in
|
||||
let%bind () = expect_eq program "type_tuple_d" (e_unit ()) (e_int 35) in
|
||||
let%bind () = expect_eq program "type_tuple_d_2" (e_unit ()) (e_string "helloworld") in
|
||||
ok ()
|
||||
|
||||
let main = test_suite "Integration (End to End)" [
|
||||
test "key hash" key_hash ;
|
||||
test "chain id" chain_id ;
|
||||
@ -1899,4 +1905,5 @@ let main = test_suite "Integration (End to End)" [
|
||||
test "simple_access (ligo)" simple_access_ligo;
|
||||
test "deep_access (ligo)" deep_access_ligo;
|
||||
test "entrypoints (ligo)" entrypoints_ligo ;
|
||||
test "type tuple destruct (mligo)" type_tuple_destruct ;
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user