Skip to content

Commit cee74af

Browse files
authored
flambda-backend: Ensure that functions are evaluated after their arguments (#353)
1 parent 954be59 commit cee74af

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

testsuite/tests/basic/eval_order_8.ml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(* TEST *)
2+
3+
(* closed, inlined *)
4+
let[@inline always] f () () = print_endline "4"
5+
let () = (let () = print_string "3" in f) (print_string "2") (print_string "1")
6+
7+
(* closed, not inlined *)
8+
let[@inline never] f () () = print_endline "4"
9+
let () = (let () = print_string "3" in f) (print_string "2") (print_string "1")
10+
11+
(* closure, inlined *)
12+
let[@inline never] g x =
13+
(let () = print_string "3" in fun () () -> print_endline x)
14+
(print_string "2") (print_string "1")
15+
let () = g "4"
16+
17+
(* closure, not inlined *)
18+
let[@inline never] g x =
19+
(let () = print_string "3" in
20+
let[@inline never] f () () = print_endline x in f)
21+
(print_string "2") (print_string "1")
22+
let () = g "4"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1234
2+
1234
3+
1234
4+
1234

0 commit comments

Comments
 (0)