Skip to content

Commit

Permalink
flambda-backend: Ensure that functions are evaluated after their argu…
Browse files Browse the repository at this point in the history
…ments (ocaml#353)
  • Loading branch information
stedolan committed Oct 27, 2021
1 parent 954be59 commit cee74af
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions testsuite/tests/basic/eval_order_8.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(* TEST *)

(* closed, inlined *)
let[@inline always] f () () = print_endline "4"
let () = (let () = print_string "3" in f) (print_string "2") (print_string "1")

(* closed, not inlined *)
let[@inline never] f () () = print_endline "4"
let () = (let () = print_string "3" in f) (print_string "2") (print_string "1")

(* closure, inlined *)
let[@inline never] g x =
(let () = print_string "3" in fun () () -> print_endline x)
(print_string "2") (print_string "1")
let () = g "4"

(* closure, not inlined *)
let[@inline never] g x =
(let () = print_string "3" in
let[@inline never] f () () = print_endline x in f)
(print_string "2") (print_string "1")
let () = g "4"
4 changes: 4 additions & 0 deletions testsuite/tests/basic/eval_order_8.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1234
1234
1234
1234

0 comments on commit cee74af

Please sign in to comment.