From 918a842c437cda6772bdcddd0e60a2634a712058 Mon Sep 17 00:00:00 2001 From: alainfrisch Date: Fri, 29 Mar 2019 16:42:22 +0100 Subject: [PATCH] Fix #8558: do not blindly use Alias binding --- bytecomp/simplif.ml | 2 +- testsuite/tests/basic/localfunction.ml | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bytecomp/simplif.ml b/bytecomp/simplif.ml index 30175417553a..d57171e8b1dd 100644 --- a/bytecomp/simplif.ml +++ b/bytecomp/simplif.ml @@ -282,7 +282,7 @@ let simplify_exits lam = xs ys Ident.Map.empty in List.fold_right2 - (fun (y, kind) l r -> Llet (Alias, kind, y, l, r)) + (fun (y, kind) l r -> Llet (Strict, kind, y, l, r)) ys ls (Lambda.rename env handler) with | Not_found -> Lstaticraise (i,ls) diff --git a/testsuite/tests/basic/localfunction.ml b/testsuite/tests/basic/localfunction.ml index 31a757e052d2..6ea7b5d76a19 100644 --- a/testsuite/tests/basic/localfunction.ml +++ b/testsuite/tests/basic/localfunction.ml @@ -21,3 +21,12 @@ let () = Printf.printf "%i\n%!" !r; assert(x1 -. x0 = x2 -. x1) (* check that we did not allocated anything between x1 and x2 *) + + +let () = + (* #8558 *) + let f () = () in + let r = ref 0 in + let g () = f (incr r) in + g (); + assert (!r = 1)