diff --git a/src/test/contracts/loop_bugs.ligo b/src/test/contracts/loop_bugs.ligo new file mode 100644 index 000000000..1a18a6758 --- /dev/null +++ b/src/test/contracts/loop_bugs.ligo @@ -0,0 +1,20 @@ +function shadowing_in_body (var nee : unit) : string is block { + var st : string := ""; + var list1 : list(string) := list "to"; "to" end; + for x in list list1 block { + const x : string = "ta"; + st := st ^ x; + } +} with st +(* should be "tata" *) + +function shadowing_assigned_in_body (var nee : unit) : string is block { + var st : string := ""; + var list1 : list(string) := list "to"; "to" end; + for x in list list1 block { + st := st ^ x; + var st : string := "ta"; + st := st ^ x; + } +} with st +(* should be "toto" ??? *) diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index f79d3e8e3..6238fb836 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -2253,6 +2253,17 @@ let no_semicolon_religo () : unit result = in ok () +let loop_bugs_ligo () : unit result = + let%bind program = type_file "./contracts/loop_bugs.ligo" in + let input = e_unit () in + let%bind () = + let expected = e_string "tata" in + expect_eq program "shadowing_in_body" input expected in + let%bind () = + let expected = e_string "toto" in + expect_eq program "shadowing_assigned_in_body" input expected in + ok () + let main = test_suite "Integration (End to End)" [ test "bytes unpack" bytes_unpack ; test "bytes unpack (mligo)" bytes_unpack_mligo ; @@ -2421,4 +2432,5 @@ let main = test_suite "Integration (End to End)" [ test "tuple type (mligo)" tuple_type_mligo ; test "tuple type (religo)" tuple_type_religo ; test "no semicolon (religo)" no_semicolon_religo ; + test "loop_bugs (ligo)" loop_bugs_ligo ; ]