diff --git a/src/passes/2-simplify/pascaligo.ml b/src/passes/2-simplify/pascaligo.ml index 54b2c2207..4dee47dec 100644 --- a/src/passes/2-simplify/pascaligo.ml +++ b/src/passes/2-simplify/pascaligo.ml @@ -1068,7 +1068,11 @@ and simpl_for_collect : Raw.for_collect -> (_ -> expression result) result = fun let%bind captured_name_list = Self_ast_simplified.fold_expression (fun (prev : type_name list) (ass_exp : expression) -> match ass_exp.expression with - | E_assign ( name , _ , _ ) -> ok (name::prev) + | E_assign ( name , _ , _ ) -> + if (String.contains name '#') then + ok prev + else + ok (name::prev) | _ -> ok prev ) [] for_body in diff --git a/src/test/contracts/loop.ligo b/src/test/contracts/loop.ligo index b873853b7..2f250cf18 100644 --- a/src/test/contracts/loop.ligo +++ b/src/test/contracts/loop.ligo @@ -136,6 +136,21 @@ function for_collection_map_k (var nee : unit) : string is block { end } with st +// function nested_for_collection (var nee : unit) : (int*string) is block { +// var myint : int := 0; +// var myst : string := ""; +// var mylist : list(int) := list 1 ; 2 ; 3 end ; +// for i : int in list mylist +// begin +// myint := myint + i ; +// var myset : set(string) := set "1" ; "2" ; "3" end ; +// for st : string in set myset +// begin +// myst := myst ^ st ; +// end +// end +// } with (myint,myst) + function dummy (const n : nat) : nat is block { while (False) block { skip } } with n diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 8a644d1b2..10f4d4d06 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -688,6 +688,9 @@ let loop () : unit result = let%bind () = let expected = (e_int 20) in expect_eq program "for_collection_comp_with_acc" input expected in + (* let%bind () = + let expected = e_pair (e_int 6) (e_string "123123123") in + expect_eq program "nested_for_collection" input expected in *) let%bind () = let ez lst = let open Ast_simplified.Combinators in