summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Yallop <yallop@gmail.com>2017-01-02 14:58:05 +0000
committerJeremy Yallop <yallop@gmail.com>2017-09-25 14:57:23 +0100
commit7432766e30470d137a7c60d3203b5f2f3548ddf2 (patch)
treef14ec2125b5ff1d8b5a831b49edd8ff011998771
parent60620e3d312763692611827934f936528212aac6 (diff)
downloadocaml-7432766e30470d137a7c60d3203b5f2f3548ddf2.tar.gz
let-rec check (tests): check that some well-formed expressions are accepted
-rw-r--r--testsuite/tests/letrec/allowed.ml69
-rw-r--r--testsuite/tests/letrec/allowed.reference0
2 files changed, 69 insertions, 0 deletions
diff --git a/testsuite/tests/letrec/allowed.ml b/testsuite/tests/letrec/allowed.ml
new file mode 100644
index 0000000000..89283b7301
--- /dev/null
+++ b/testsuite/tests/letrec/allowed.ml
@@ -0,0 +1,69 @@
+let rec x = (x; ());;
+
+let rec x = let x = () in x;;
+
+let rec x = [y]
+and y = let x = () in x;;
+
+let rec x = [y]
+and y = let rec x = () in x;;
+
+let rec x =
+ let a = x in
+ fun () -> a ()
+and y =
+ [x];;
+
+let rec x = let module M = struct let f = x end in ();;
+
+module type T = sig val y: int end
+
+let rec x = let module M =
+ struct
+ module N =
+ struct
+ let y = x
+ end
+ end
+ in fun () -> ignore (M.N.y ());;
+
+let rec x = "x";;
+
+class c = object end
+let rec x = fun () -> new c;;
+
+let rec x = (y, y)
+and y = fun () -> ignore x;;
+
+let rec x = Some y
+and y = fun () -> ignore x
+;;
+
+let rec x = `A y
+and y = fun () -> ignore x
+;;
+
+let rec x = { contents = y }
+and y = fun () -> ignore x;;
+
+let r = ref (fun () -> ())
+let rec x = fun () -> r := x;;
+
+let rec x = fun () -> y.contents and y = { contents = 3 };;
+
+let rec x = function
+ Some _ -> ignore (y [])
+ | None -> ignore (y [])
+and y = function
+ [] -> ignore (x None)
+ | _ :: _ -> ignore (x None)
+ ;;
+
+let rec x = lazy (Lazy.force x + Lazy.force x)
+ ;;
+
+let rec x = { x with contents = 3 };;
+
+let rec x = let y = (x; ()) in y;;
+
+let rec x = [|y|] and y = 0;;
diff --git a/testsuite/tests/letrec/allowed.reference b/testsuite/tests/letrec/allowed.reference
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/letrec/allowed.reference