From 1401d03d62a927b7714c12cd1a1b39339610f584 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Mon, 7 Oct 2019 11:53:07 +0200 Subject: [PATCH 1/7] Parser patch from Christian --- src/passes/1-parser/pascaligo/Parser.mly | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/passes/1-parser/pascaligo/Parser.mly b/src/passes/1-parser/pascaligo/Parser.mly index a1902bade..f4d25bbe5 100644 --- a/src/passes/1-parser/pascaligo/Parser.mly +++ b/src/passes/1-parser/pascaligo/Parser.mly @@ -591,7 +591,11 @@ assignment: in {region; value}} rhs: - expr { Expr $1 } + expr { + match $1 with + EConstr (NoneExpr e) -> (NoneExpr e : rhs) + | e -> Expr e + } lhs: path { Path $1 } From 08a3e08f5718a543c02b555a7d5e420cda0e49b7 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Mon, 7 Oct 2019 11:54:27 +0200 Subject: [PATCH 2/7] add a new T_constant in ast_simplified and ast_typed --- src/passes/2-simplify/pascaligo.ml | 3 ++- src/passes/4-typer/typer.ml | 2 ++ src/passes/6-transpiler/transpiler.ml | 2 ++ src/passes/6-transpiler/untranspiler.ml | 4 +++- src/stages/ast_typed/combinators.ml | 3 ++- src/stages/ast_typed/combinators_environment.ml | 2 +- src/stages/ast_typed/misc.ml | 3 +++ src/test/contracts/option.ligo | 9 +++++++++ src/test/integration_tests.ml | 4 ++++ 9 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/passes/2-simplify/pascaligo.ml b/src/passes/2-simplify/pascaligo.ml index 31e739f36..8fe81f388 100644 --- a/src/passes/2-simplify/pascaligo.ml +++ b/src/passes/2-simplify/pascaligo.ml @@ -792,7 +792,8 @@ and simpl_single_instruction : Raw.single_instr -> (_ -> expression result) resu let (a , loc) = r_split a in let%bind value_expr = match a.rhs with | Expr e -> simpl_expression e - | NoneExpr reg -> fail @@ unsupported_ass_None reg + (* | NoneExpr reg -> fail @@ unsupported_ass_None reg *) + | NoneExpr reg -> simpl_expression (Raw.EConstr (Raw.NoneExpr reg)) in match a.lhs with | Path path -> ( diff --git a/src/passes/4-typer/typer.ml b/src/passes/4-typer/typer.ml index 391239506..7eba933bf 100644 --- a/src/passes/4-typer/typer.ml +++ b/src/passes/4-typer/typer.ml @@ -615,6 +615,8 @@ and type_expression : environment -> ?tv_opt:O.type_value -> I.expression -> O.a let output_type = body.type_annotation in return (E_lambda {binder = fst binder ; body}) (t_function input_type output_type ()) ) + | E_constant ("NONE", []) -> + return (E_constant ("NONE", [])) (t_option_none ()) | E_constant (name, lst) -> let%bind lst' = bind_list @@ List.map (type_expression e) lst in let tv_lst = List.map get_type_annotation lst' in diff --git a/src/passes/6-transpiler/transpiler.ml b/src/passes/6-transpiler/transpiler.ml index 0cef7b26b..acc4bd7e1 100644 --- a/src/passes/6-transpiler/transpiler.ml +++ b/src/passes/6-transpiler/transpiler.ml @@ -130,6 +130,8 @@ let rec transpile_type (t:AST.type_value) : type_value result = | T_constant ("option", [o]) -> let%bind o' = transpile_type o in ok (T_option o') + | T_constant ("option_none", []) -> + ok (T_option (T_base Base_unit)) | T_constant (name , _lst) -> fail @@ unrecognized_type_constant name (* TODO hmm *) | T_sum m -> diff --git a/src/passes/6-transpiler/untranspiler.ml b/src/passes/6-transpiler/untranspiler.ml index 78c41cca8..08ed0d141 100644 --- a/src/passes/6-transpiler/untranspiler.ml +++ b/src/passes/6-transpiler/untranspiler.ml @@ -107,12 +107,14 @@ let rec untranspile (v : value) (t : AST.type_value) : AST.annotated_expression get_string v in return (E_literal (Literal_address n)) ) + | T_constant ("option_none", []) -> + ok e_a_empty_none | T_constant ("option", [o]) -> ( let%bind opt = trace_strong (wrong_mini_c_value "option" v) @@ get_option v in match opt with - | None -> ok (e_a_empty_none o) + | None -> ok e_a_empty_none | Some s -> let%bind s' = untranspile s o in ok (e_a_empty_some s') diff --git a/src/stages/ast_typed/combinators.ml b/src/stages/ast_typed/combinators.ml index d9dcebb73..5ae376b9d 100644 --- a/src/stages/ast_typed/combinators.ml +++ b/src/stages/ast_typed/combinators.ml @@ -25,6 +25,7 @@ let t_tez ?s () : type_value = make_t (T_constant ("tez", [])) s let t_timestamp ?s () : type_value = make_t (T_constant ("timestamp", [])) s let t_unit ?s () : type_value = make_t (T_constant ("unit", [])) s let t_option o ?s () : type_value = make_t (T_constant ("option", [o])) s +let t_option_none ?s () : type_value = make_t (T_constant ("option_none", [])) s let t_tuple lst ?s () : type_value = make_t (T_tuple lst) s let t_list t ?s () : type_value = make_t (T_constant ("list", [t])) s let t_set t ?s () : type_value = make_t (T_constant ("set", [t])) s @@ -254,7 +255,7 @@ let e_a_address s = make_a_e (e_address s) (t_address ()) let e_a_pair a b = make_a_e (e_pair a b) (t_pair a.type_annotation b.type_annotation ()) let e_a_some s = make_a_e (e_some s) (t_option s.type_annotation ()) let e_a_lambda l in_ty out_ty = make_a_e (e_lambda l) (t_function in_ty out_ty ()) -let e_a_none t = make_a_e e_none (t_option t ()) +let e_a_none = make_a_e e_none (t_option_none ()) let e_a_tuple lst = make_a_e (E_tuple lst) (t_tuple (List.map get_type_annotation lst) ()) let e_a_record r = make_a_e (e_record r) (t_record (SMap.map get_type_annotation r) ()) let e_a_application a b = make_a_e (e_application a b) (get_type_annotation b) diff --git a/src/stages/ast_typed/combinators_environment.ml b/src/stages/ast_typed/combinators_environment.ml index 1446c8780..3cea2fd1d 100644 --- a/src/stages/ast_typed/combinators_environment.ml +++ b/src/stages/ast_typed/combinators_environment.ml @@ -12,7 +12,7 @@ let e_a_empty_string s = e_a_string s Environment.full_empty let e_a_empty_address s = e_a_address s Environment.full_empty let e_a_empty_pair a b = e_a_pair a b Environment.full_empty let e_a_empty_some s = e_a_some s Environment.full_empty -let e_a_empty_none t = e_a_none t Environment.full_empty +let e_a_empty_none = e_a_none Environment.full_empty let e_a_empty_tuple lst = e_a_tuple lst Environment.full_empty let e_a_empty_record r = e_a_record r Environment.full_empty let e_a_empty_map lst k v = e_a_map lst k v Environment.full_empty diff --git a/src/stages/ast_typed/misc.ml b/src/stages/ast_typed/misc.ml index 5ba66b4ea..b7fb63f76 100644 --- a/src/stages/ast_typed/misc.ml +++ b/src/stages/ast_typed/misc.ml @@ -296,6 +296,9 @@ let rec assert_type_value_eq (a, b: (type_value * type_value)) : unit result = m bind_list_iter assert_type_value_eq (List.combine ta tb) ) | T_tuple _, _ -> fail @@ different_kinds a b + | T_constant ("option", _), T_constant ("option_none", []) | + T_constant ("option_none", []), T_constant ("option", _) -> + ok () | T_constant (ca, lsta), T_constant (cb, lstb) -> ( let%bind _ = trace_strong (different_size_constants a b) diff --git a/src/test/contracts/option.ligo b/src/test/contracts/option.ligo index c2d36439d..9abf2c845 100644 --- a/src/test/contracts/option.ligo +++ b/src/test/contracts/option.ligo @@ -4,3 +4,12 @@ type foobar is option(int) const s : foobar = Some(42) const n : foobar = None + +function assign (var m : int) : foobar is + var coco : foobar := None; + block +{ + coco := Some(m); + coco := None; +} +with coco diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 16a4c7d69..b558d08dd 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -368,6 +368,10 @@ let option () : unit result = let expected = e_typed_none t_int in expect_eq_evaluate program "n" expected in + let%bind () = + let expected = e_typed_none t_int in + expect_eq program "assign" (e_int 12) expected + in ok () let moption () : unit result = From 3a3cfa341ab4405c31666f5047f36a13d31c0762 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Mon, 7 Oct 2019 12:03:19 +0200 Subject: [PATCH 3/7] cleaning --- src/passes/2-simplify/pascaligo.ml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/passes/2-simplify/pascaligo.ml b/src/passes/2-simplify/pascaligo.ml index 8fe81f388..2e0eee337 100644 --- a/src/passes/2-simplify/pascaligo.ml +++ b/src/passes/2-simplify/pascaligo.ml @@ -26,16 +26,6 @@ module Errors = struct ] in error ~data title message - let unsupported_ass_None region = - let title () = "assignment of None" in - let message () = - Format.asprintf "assignments of None are not supported yet" in - let data = [ - ("none_expr", - fun () -> Format.asprintf "%a" Location.pp_lift @@ region) - ] in - error ~data title message - let bad_bytes loc str = let title () = "bad bytes string" in let message () = @@ -792,8 +782,7 @@ and simpl_single_instruction : Raw.single_instr -> (_ -> expression result) resu let (a , loc) = r_split a in let%bind value_expr = match a.rhs with | Expr e -> simpl_expression e - (* | NoneExpr reg -> fail @@ unsupported_ass_None reg *) - | NoneExpr reg -> simpl_expression (Raw.EConstr (Raw.NoneExpr reg)) + | NoneExpr reg -> simpl_expression (EConstr (NoneExpr reg)) in match a.lhs with | Path path -> ( From 3a14ef26ef3092e70356f70a9386e4bda897ff40 Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Mon, 7 Oct 2019 08:11:46 -0500 Subject: [PATCH 4/7] Simplify? --- src/passes/1-parser/pascaligo/Parser.mly | 6 +----- src/passes/2-simplify/pascaligo.ml | 2 +- src/passes/4-typer/typer.ml | 8 ++++++-- src/passes/6-transpiler/transpiler.ml | 2 -- src/passes/6-transpiler/untranspiler.ml | 4 +--- src/stages/ast_typed/combinators.ml | 3 +-- src/stages/ast_typed/combinators_environment.ml | 2 +- src/stages/ast_typed/misc.ml | 3 --- src/test/contracts/option.ligo | 2 +- 9 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/passes/1-parser/pascaligo/Parser.mly b/src/passes/1-parser/pascaligo/Parser.mly index f4d25bbe5..a1902bade 100644 --- a/src/passes/1-parser/pascaligo/Parser.mly +++ b/src/passes/1-parser/pascaligo/Parser.mly @@ -591,11 +591,7 @@ assignment: in {region; value}} rhs: - expr { - match $1 with - EConstr (NoneExpr e) -> (NoneExpr e : rhs) - | e -> Expr e - } + expr { Expr $1 } lhs: path { Path $1 } diff --git a/src/passes/2-simplify/pascaligo.ml b/src/passes/2-simplify/pascaligo.ml index 2e0eee337..ddb3d7bd8 100644 --- a/src/passes/2-simplify/pascaligo.ml +++ b/src/passes/2-simplify/pascaligo.ml @@ -782,7 +782,7 @@ and simpl_single_instruction : Raw.single_instr -> (_ -> expression result) resu let (a , loc) = r_split a in let%bind value_expr = match a.rhs with | Expr e -> simpl_expression e - | NoneExpr reg -> simpl_expression (EConstr (NoneExpr reg)) + | NoneExpr reg -> simpl_expression (EConstr (NoneExpr reg)) in match a.lhs with | Path path -> ( diff --git a/src/passes/4-typer/typer.ml b/src/passes/4-typer/typer.ml index 7eba933bf..7acbf5138 100644 --- a/src/passes/4-typer/typer.ml +++ b/src/passes/4-typer/typer.ml @@ -616,7 +616,11 @@ and type_expression : environment -> ?tv_opt:O.type_value -> I.expression -> O.a return (E_lambda {binder = fst binder ; body}) (t_function input_type output_type ()) ) | E_constant ("NONE", []) -> - return (E_constant ("NONE", [])) (t_option_none ()) + let%bind tv_opt = bind_map_option get_t_option tv_opt in + begin match tv_opt with + | None -> fail @@ simple_info "None without a type annotation" + | Some tv -> return (E_constant ("NONE", [])) (t_option tv ()) + end | E_constant (name, lst) -> let%bind lst' = bind_list @@ List.map (type_expression e) lst in let tv_lst = List.map get_type_annotation lst' in @@ -728,7 +732,7 @@ and type_expression : environment -> ?tv_opt:O.type_value -> I.expression -> O.a fail @@ not_supported_yet "assign expressions with maps are not supported yet" ae in bind_fold_list aux (typed_name.type_value , []) path in - let%bind expr' = type_expression e expr in + let%bind expr' = type_expression e ~tv_opt:assign_tv expr in let t_expr' = get_type_annotation expr' in let%bind () = trace_strong (type_error diff --git a/src/passes/6-transpiler/transpiler.ml b/src/passes/6-transpiler/transpiler.ml index acc4bd7e1..0cef7b26b 100644 --- a/src/passes/6-transpiler/transpiler.ml +++ b/src/passes/6-transpiler/transpiler.ml @@ -130,8 +130,6 @@ let rec transpile_type (t:AST.type_value) : type_value result = | T_constant ("option", [o]) -> let%bind o' = transpile_type o in ok (T_option o') - | T_constant ("option_none", []) -> - ok (T_option (T_base Base_unit)) | T_constant (name , _lst) -> fail @@ unrecognized_type_constant name (* TODO hmm *) | T_sum m -> diff --git a/src/passes/6-transpiler/untranspiler.ml b/src/passes/6-transpiler/untranspiler.ml index 08ed0d141..78c41cca8 100644 --- a/src/passes/6-transpiler/untranspiler.ml +++ b/src/passes/6-transpiler/untranspiler.ml @@ -107,14 +107,12 @@ let rec untranspile (v : value) (t : AST.type_value) : AST.annotated_expression get_string v in return (E_literal (Literal_address n)) ) - | T_constant ("option_none", []) -> - ok e_a_empty_none | T_constant ("option", [o]) -> ( let%bind opt = trace_strong (wrong_mini_c_value "option" v) @@ get_option v in match opt with - | None -> ok e_a_empty_none + | None -> ok (e_a_empty_none o) | Some s -> let%bind s' = untranspile s o in ok (e_a_empty_some s') diff --git a/src/stages/ast_typed/combinators.ml b/src/stages/ast_typed/combinators.ml index 5ae376b9d..d9dcebb73 100644 --- a/src/stages/ast_typed/combinators.ml +++ b/src/stages/ast_typed/combinators.ml @@ -25,7 +25,6 @@ let t_tez ?s () : type_value = make_t (T_constant ("tez", [])) s let t_timestamp ?s () : type_value = make_t (T_constant ("timestamp", [])) s let t_unit ?s () : type_value = make_t (T_constant ("unit", [])) s let t_option o ?s () : type_value = make_t (T_constant ("option", [o])) s -let t_option_none ?s () : type_value = make_t (T_constant ("option_none", [])) s let t_tuple lst ?s () : type_value = make_t (T_tuple lst) s let t_list t ?s () : type_value = make_t (T_constant ("list", [t])) s let t_set t ?s () : type_value = make_t (T_constant ("set", [t])) s @@ -255,7 +254,7 @@ let e_a_address s = make_a_e (e_address s) (t_address ()) let e_a_pair a b = make_a_e (e_pair a b) (t_pair a.type_annotation b.type_annotation ()) let e_a_some s = make_a_e (e_some s) (t_option s.type_annotation ()) let e_a_lambda l in_ty out_ty = make_a_e (e_lambda l) (t_function in_ty out_ty ()) -let e_a_none = make_a_e e_none (t_option_none ()) +let e_a_none t = make_a_e e_none (t_option t ()) let e_a_tuple lst = make_a_e (E_tuple lst) (t_tuple (List.map get_type_annotation lst) ()) let e_a_record r = make_a_e (e_record r) (t_record (SMap.map get_type_annotation r) ()) let e_a_application a b = make_a_e (e_application a b) (get_type_annotation b) diff --git a/src/stages/ast_typed/combinators_environment.ml b/src/stages/ast_typed/combinators_environment.ml index 3cea2fd1d..1446c8780 100644 --- a/src/stages/ast_typed/combinators_environment.ml +++ b/src/stages/ast_typed/combinators_environment.ml @@ -12,7 +12,7 @@ let e_a_empty_string s = e_a_string s Environment.full_empty let e_a_empty_address s = e_a_address s Environment.full_empty let e_a_empty_pair a b = e_a_pair a b Environment.full_empty let e_a_empty_some s = e_a_some s Environment.full_empty -let e_a_empty_none = e_a_none Environment.full_empty +let e_a_empty_none t = e_a_none t Environment.full_empty let e_a_empty_tuple lst = e_a_tuple lst Environment.full_empty let e_a_empty_record r = e_a_record r Environment.full_empty let e_a_empty_map lst k v = e_a_map lst k v Environment.full_empty diff --git a/src/stages/ast_typed/misc.ml b/src/stages/ast_typed/misc.ml index b7fb63f76..5ba66b4ea 100644 --- a/src/stages/ast_typed/misc.ml +++ b/src/stages/ast_typed/misc.ml @@ -296,9 +296,6 @@ let rec assert_type_value_eq (a, b: (type_value * type_value)) : unit result = m bind_list_iter assert_type_value_eq (List.combine ta tb) ) | T_tuple _, _ -> fail @@ different_kinds a b - | T_constant ("option", _), T_constant ("option_none", []) | - T_constant ("option_none", []), T_constant ("option", _) -> - ok () | T_constant (ca, lsta), T_constant (cb, lstb) -> ( let%bind _ = trace_strong (different_size_constants a b) diff --git a/src/test/contracts/option.ligo b/src/test/contracts/option.ligo index 9abf2c845..d3d1ef36c 100644 --- a/src/test/contracts/option.ligo +++ b/src/test/contracts/option.ligo @@ -8,7 +8,7 @@ const n : foobar = None function assign (var m : int) : foobar is var coco : foobar := None; block -{ +{ coco := Some(m); coco := None; } From 1c2c6cbc43985ce3dd4aa3345f277f618ec6a9f9 Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Mon, 7 Oct 2019 08:47:51 -0500 Subject: [PATCH 5/7] Delete unused NoneExpr --- src/passes/1-parser/pascaligo/AST.ml | 2 -- src/passes/1-parser/pascaligo/AST.mli | 1 - src/passes/1-parser/pascaligo/ParserLog.ml | 1 - src/passes/2-simplify/pascaligo.ml | 1 - 4 files changed, 5 deletions(-) diff --git a/src/passes/1-parser/pascaligo/AST.ml b/src/passes/1-parser/pascaligo/AST.ml index 214daaafe..8a95555eb 100644 --- a/src/passes/1-parser/pascaligo/AST.ml +++ b/src/passes/1-parser/pascaligo/AST.ml @@ -408,7 +408,6 @@ and lhs = and rhs = Expr of expr -| NoneExpr of c_None and loop = While of while_loop reg @@ -760,7 +759,6 @@ let lhs_to_region : lhs -> Region.t = function let rhs_to_region = function Expr e -> expr_to_region e -| NoneExpr r -> r let selection_to_region = function FieldName {region; _} diff --git a/src/passes/1-parser/pascaligo/AST.mli b/src/passes/1-parser/pascaligo/AST.mli index 15e7e9883..f3a22e743 100644 --- a/src/passes/1-parser/pascaligo/AST.mli +++ b/src/passes/1-parser/pascaligo/AST.mli @@ -392,7 +392,6 @@ and lhs = and rhs = Expr of expr -| NoneExpr of c_None and loop = While of while_loop reg diff --git a/src/passes/1-parser/pascaligo/ParserLog.ml b/src/passes/1-parser/pascaligo/ParserLog.ml index 4c8223aab..b6e9d651f 100644 --- a/src/passes/1-parser/pascaligo/ParserLog.ml +++ b/src/passes/1-parser/pascaligo/ParserLog.ml @@ -311,7 +311,6 @@ and print_assignment {value; _} = and print_rhs = function Expr e -> print_expr e -| NoneExpr r -> print_token r "None" and print_lhs = function Path path -> print_path path diff --git a/src/passes/2-simplify/pascaligo.ml b/src/passes/2-simplify/pascaligo.ml index ddb3d7bd8..f536a409a 100644 --- a/src/passes/2-simplify/pascaligo.ml +++ b/src/passes/2-simplify/pascaligo.ml @@ -782,7 +782,6 @@ and simpl_single_instruction : Raw.single_instr -> (_ -> expression result) resu let (a , loc) = r_split a in let%bind value_expr = match a.rhs with | Expr e -> simpl_expression e - | NoneExpr reg -> simpl_expression (EConstr (NoneExpr reg)) in match a.lhs with | Path path -> ( From e2c831a23157276caac74611d6d9e4b3433431b5 Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Mon, 7 Oct 2019 09:12:10 -0500 Subject: [PATCH 6/7] Simplify more --- src/passes/4-typer/typer.ml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/passes/4-typer/typer.ml b/src/passes/4-typer/typer.ml index 7acbf5138..28258b9fb 100644 --- a/src/passes/4-typer/typer.ml +++ b/src/passes/4-typer/typer.ml @@ -615,12 +615,6 @@ and type_expression : environment -> ?tv_opt:O.type_value -> I.expression -> O.a let output_type = body.type_annotation in return (E_lambda {binder = fst binder ; body}) (t_function input_type output_type ()) ) - | E_constant ("NONE", []) -> - let%bind tv_opt = bind_map_option get_t_option tv_opt in - begin match tv_opt with - | None -> fail @@ simple_info "None without a type annotation" - | Some tv -> return (E_constant ("NONE", [])) (t_option tv ()) - end | E_constant (name, lst) -> let%bind lst' = bind_list @@ List.map (type_expression e) lst in let tv_lst = List.map get_type_annotation lst' in From 36ec771adfd2eec9f64e1ca3abb99d23d3bd737c Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Mon, 7 Oct 2019 09:24:56 -0500 Subject: [PATCH 7/7] Remove singleton inductive type --- src/passes/1-parser/pascaligo/AST.ml | 6 ++---- src/passes/1-parser/pascaligo/AST.mli | 3 +-- src/passes/1-parser/pascaligo/Parser.mly | 2 +- src/passes/1-parser/pascaligo/ParserLog.ml | 3 +-- src/passes/2-simplify/pascaligo.ml | 4 +--- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/passes/1-parser/pascaligo/AST.ml b/src/passes/1-parser/pascaligo/AST.ml index 8a95555eb..44c6c0734 100644 --- a/src/passes/1-parser/pascaligo/AST.ml +++ b/src/passes/1-parser/pascaligo/AST.ml @@ -406,8 +406,7 @@ and lhs = Path of path | MapPath of map_lookup reg -and rhs = - Expr of expr +and rhs = expr and loop = While of while_loop reg @@ -757,8 +756,7 @@ let lhs_to_region : lhs -> Region.t = function Path path -> path_to_region path | MapPath {region; _} -> region -let rhs_to_region = function - Expr e -> expr_to_region e +let rhs_to_region = expr_to_region let selection_to_region = function FieldName {region; _} diff --git a/src/passes/1-parser/pascaligo/AST.mli b/src/passes/1-parser/pascaligo/AST.mli index f3a22e743..4984830e0 100644 --- a/src/passes/1-parser/pascaligo/AST.mli +++ b/src/passes/1-parser/pascaligo/AST.mli @@ -390,8 +390,7 @@ and lhs = Path of path | MapPath of map_lookup reg -and rhs = - Expr of expr +and rhs = expr and loop = While of while_loop reg diff --git a/src/passes/1-parser/pascaligo/Parser.mly b/src/passes/1-parser/pascaligo/Parser.mly index a1902bade..bc99f9176 100644 --- a/src/passes/1-parser/pascaligo/Parser.mly +++ b/src/passes/1-parser/pascaligo/Parser.mly @@ -591,7 +591,7 @@ assignment: in {region; value}} rhs: - expr { Expr $1 } + expr { $1 } lhs: path { Path $1 } diff --git a/src/passes/1-parser/pascaligo/ParserLog.ml b/src/passes/1-parser/pascaligo/ParserLog.ml index b6e9d651f..3be60d699 100644 --- a/src/passes/1-parser/pascaligo/ParserLog.ml +++ b/src/passes/1-parser/pascaligo/ParserLog.ml @@ -309,8 +309,7 @@ and print_assignment {value; _} = print_token assign ":="; print_rhs rhs -and print_rhs = function - Expr e -> print_expr e +and print_rhs e = print_expr e and print_lhs = function Path path -> print_path path diff --git a/src/passes/2-simplify/pascaligo.ml b/src/passes/2-simplify/pascaligo.ml index f536a409a..5627c49f6 100644 --- a/src/passes/2-simplify/pascaligo.ml +++ b/src/passes/2-simplify/pascaligo.ml @@ -780,9 +780,7 @@ and simpl_single_instruction : Raw.single_instr -> (_ -> expression result) resu ) | Assign a -> ( let (a , loc) = r_split a in - let%bind value_expr = match a.rhs with - | Expr e -> simpl_expression e - in + let%bind value_expr = simpl_expression a.rhs in match a.lhs with | Path path -> ( let (name , path') = simpl_path path in