diff --git a/src/passes/2-simplify/pascaligo.ml b/src/passes/2-simplify/pascaligo.ml index ec38004b3..a7314317d 100644 --- a/src/passes/2-simplify/pascaligo.ml +++ b/src/passes/2-simplify/pascaligo.ml @@ -1189,7 +1189,7 @@ and simpl_for_collect : Raw.for_collect -> (_ -> expression result) result = fun (* STEP 9 *) let final_sequence = match reassign_sequence with (* None case means that no variables were captured *) - | None -> e_let_in ("#COMPILER#folded_record", None) fold (e_skip ()) + | None -> e_skip () | Some seq -> e_let_in ("#COMPILER#folded_record", None) fold seq in return_statement @@ final_sequence diff --git a/src/test/contracts/loop.ligo b/src/test/contracts/loop.ligo index 10137c07a..7aaa4d7eb 100644 --- a/src/test/contracts/loop.ligo +++ b/src/test/contracts/loop.ligo @@ -46,6 +46,27 @@ function for_collection_set (var nee : unit) : (int * string) is block { end } with (acc, st) +// function for_collection_assignements_in_ifs (var nee : unit) : int is block { +// var acc : int := 0 ; +// var myset : set(int) := set 1 ; 2 ; 3 end ; +// for x : int in set myset +// begin +// if (x=1) then +// acc := acc + x ; +// else +// acc := acc + 10 ; +// end +// } with acc + +function for_collection_empty (var nee : unit) : int is block { + var acc : int := 0 ; + var myset : set(int) := set 1 ; 2 ; 3 end ; + for x : int in set myset + begin + skip ; + end +} with acc + // function for_collection_map (var nee : unit) : (int * string) is block { // var acc : int := 0 ; // var st : string := "" ; diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 3ed6d871e..26a1fcc63 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -674,6 +674,11 @@ let loop () : unit result = let expected = e_pair (e_int 6) (e_string "totototo") in expect_eq program "for_collection_set" input expected in + let%bind () = + let input = e_unit () in + let expected = (e_int 0) in + expect_eq program "for_collection_empty" input expected + in ok () (* Don't know how to assert parse error happens in this test framework