Add support for tuple destructuring in ReasonLIGO
This commit is contained in:
parent
d351d585b0
commit
fbb622cc03
@ -428,8 +428,22 @@ fun_expr:
|
||||
{p.value with inside = arg_to_pattern p.value.inside}
|
||||
in PPar {p with value}
|
||||
| EUnit u -> PUnit u
|
||||
| e -> let open! SyntaxError
|
||||
in raise (Error (WrongFunctionArguments e))
|
||||
| ETuple { value; region } ->
|
||||
PTuple { value = Utils.nsepseq_map arg_to_pattern value; region}
|
||||
| EAnnot {region; value = {inside = ETuple _ as t, colon, typ; _}} ->
|
||||
let value = { pattern = arg_to_pattern t; colon; type_expr = typ} in
|
||||
PPar {
|
||||
value = {
|
||||
lpar = Region.ghost;
|
||||
rpar = Region.ghost;
|
||||
inside = PTyped {region; value}
|
||||
};
|
||||
region
|
||||
}
|
||||
| e -> (
|
||||
let open! SyntaxError in
|
||||
raise (Error (WrongFunctionArguments e))
|
||||
)
|
||||
in
|
||||
let fun_args_to_pattern = function
|
||||
EAnnot {
|
||||
|
@ -1946,6 +1946,11 @@ let tuple_param_destruct () : unit result =
|
||||
let%bind () = expect_eq program "sum" (e_tuple [e_int 10; e_int 10]) (e_int 20)
|
||||
in ok ()
|
||||
|
||||
let tuple_param_destruct_religo () : unit result =
|
||||
let%bind program = retype_file "./contracts/tuple_param_destruct.religo" in
|
||||
let%bind () = expect_eq program "sum" (e_tuple [e_int 10; e_int 10]) (e_int 20)
|
||||
in ok ()
|
||||
|
||||
let let_in_multi_bind () : unit result =
|
||||
let%bind program = mtype_file "./contracts/let_in_multi_bind.mligo" in
|
||||
let%bind () = expect_eq program "sum" (e_tuple [e_int 10; e_int 10]) (e_int 20) in
|
||||
@ -2159,6 +2164,7 @@ let main = test_suite "Integration (End to End)" [
|
||||
test "attributes (religo)" attributes_religo;
|
||||
test "let in multi-bind (mligo)" let_in_multi_bind ;
|
||||
test "tuple param destruct (mligo)" tuple_param_destruct ;
|
||||
test "tuple param destruct (religo)" tuple_param_destruct_religo ;
|
||||
test "empty case" empty_case ;
|
||||
test "empty case (mligo)" empty_case_mligo ;
|
||||
test "empty case (religo)" empty_case_religo ;
|
||||
|
Loading…
Reference in New Issue
Block a user