empty for collection loop
This commit is contained in:
parent
37570c6a40
commit
e77f3e4903
@ -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
|
||||
|
||||
|
@ -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 := "" ;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user