summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMark Shinwell <mshinwell@gmail.com>2019-06-03 16:24:26 +0100
committerAlain Frisch <alain@frisch.fr>2019-06-03 17:24:26 +0200
commitb1b081a54a7b8857fa4cb1314b557e26ee498acd (patch)
tree0e24f933b56d814161fda5f0420eb980f0e1158d /testsuite
parent16ce302ee1d31a4afc932d3dc85173b4988f5218 (diff)
downloadocaml-b1b081a54a7b8857fa4cb1314b557e26ee498acd.tar.gz
Don't apply local function optimisation for Tupled functions (fixes #8705) (#8706)
* Don't apply local function optimisation for Tupled functions * Add test cases * Remove wrong hunk
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/local-functions/ocamltests2
-rw-r--r--testsuite/tests/local-functions/tupled.ml11
-rw-r--r--testsuite/tests/local-functions/tupled2.ml16
3 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/tests/local-functions/ocamltests b/testsuite/tests/local-functions/ocamltests
new file mode 100644
index 0000000000..65f8036957
--- /dev/null
+++ b/testsuite/tests/local-functions/ocamltests
@@ -0,0 +1,2 @@
+tupled.ml
+tupled2.ml
diff --git a/testsuite/tests/local-functions/tupled.ml b/testsuite/tests/local-functions/tupled.ml
new file mode 100644
index 0000000000..aef5aacb27
--- /dev/null
+++ b/testsuite/tests/local-functions/tupled.ml
@@ -0,0 +1,11 @@
+(* TEST
+*)
+
+(* PR#8705 *)
+let () =
+ let tupled (x, y) =
+ print_string "";
+ fun z -> x, y, z
+ in
+ let a, b, c = tupled (0, 1) 2 in
+ assert (a = 0 && b = 1 && c = 2)
diff --git a/testsuite/tests/local-functions/tupled2.ml b/testsuite/tests/local-functions/tupled2.ml
new file mode 100644
index 0000000000..e1564980d6
--- /dev/null
+++ b/testsuite/tests/local-functions/tupled2.ml
@@ -0,0 +1,16 @@
+(* TEST
+*)
+
+(* PR#8705 *)
+
+let test x =
+ let tupled (x, y) = (); fun () -> [|x; y|] in
+ match x with
+ | None -> [| |]
+ | Some (x, y) -> tupled (x, y) ()
+
+let expected = "Hello "
+
+let result = (test (Some (expected, "World!"))).(0)
+
+let () = assert (String.equal expected result)