1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
(* TEST
expect;
*)
module rec A: sig val x: int end = struct let x = B.x end
and B:sig val x: int end = struct let x = E.y end
and C:sig val x: int end = struct let x = B.x end
and D:sig val x: int end = struct let x = C.x end
and E:sig val x: int val y:int end = struct let x = D.x let y = 0 end
[%%expect {|
Line 2, characters 27-49:
2 | and B:sig val x: int end = struct let x = E.y end
^^^^^^^^^^^^^^^^^^^^^^
Error: Cannot safely evaluate the definition of the following cycle
of recursively-defined modules: B -> E -> D -> C -> B.
There are no safe modules in this cycle (see manual section 12.2).
Line 2, characters 10-20:
2 | and B:sig val x: int end = struct let x = E.y end
^^^^^^^^^^
Module "B" defines an unsafe value, "x" .
Line 5, characters 10-20:
5 | and E:sig val x: int val y:int end = struct let x = D.x let y = 0 end
^^^^^^^^^^
Module "E" defines an unsafe value, "x" .
Line 4, characters 10-20:
4 | and D:sig val x: int end = struct let x = C.x end
^^^^^^^^^^
Module "D" defines an unsafe value, "x" .
Line 3, characters 10-20:
3 | and C:sig val x: int end = struct let x = B.x end
^^^^^^^^^^
Module "C" defines an unsafe value, "x" .
|}]
type t = ..
module rec A: sig type t += A end = struct type t += A = B.A end
and B:sig type t += A end = struct type t += A = A.A end
[%%expect {|
type t = ..
Line 2, characters 36-64:
2 | module rec A: sig type t += A end = struct type t += A = B.A end
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Cannot safely evaluate the definition of the following cycle
of recursively-defined modules: A -> B -> A.
There are no safe modules in this cycle (see manual section 12.2).
Line 2, characters 28-29:
2 | module rec A: sig type t += A end = struct type t += A = B.A end
^
Module "A" defines an unsafe extension constructor, "A" .
Line 3, characters 20-21:
3 | and B:sig type t += A end = struct type t += A = A.A end
^
Module "B" defines an unsafe extension constructor, "A" .
|}]
module rec A: sig
module F: functor(X:sig end) -> sig end
val f: unit -> unit
end = struct
module F(X:sig end) = struct end
let f () = B.value
end
and B: sig val value: unit end = struct let value = A.f () end
[%%expect {|
Lines 4-7, characters 6-3:
4 | ......struct
5 | module F(X:sig end) = struct end
6 | let f () = B.value
7 | end
Error: Cannot safely evaluate the definition of the following cycle
of recursively-defined modules: A -> B -> A.
There are no safe modules in this cycle (see manual section 12.2).
Line 2, characters 2-41:
2 | module F: functor(X:sig end) -> sig end
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Module "A" defines an unsafe functor, "F" .
Line 8, characters 11-26:
8 | and B: sig val value: unit end = struct let value = A.f () end
^^^^^^^^^^^^^^^
Module "B" defines an unsafe value, "value" .
|}]
module F(X: sig module type t module M: t end) = struct
module rec A: sig
module M: X.t
val f: unit -> unit
end = struct
module M = X.M
let f () = B.value
end
and B: sig val value: unit end = struct let value = A.f () end
end
[%%expect {|
Lines 5-8, characters 8-5:
5 | ........struct
6 | module M = X.M
7 | let f () = B.value
8 | end
Error: Cannot safely evaluate the definition of the following cycle
of recursively-defined modules: A -> B -> A.
There are no safe modules in this cycle (see manual section 12.2).
Line 3, characters 4-17:
3 | module M: X.t
^^^^^^^^^^^^^
Module "A" defines an unsafe module, "M" .
Line 9, characters 13-28:
9 | and B: sig val value: unit end = struct let value = A.f () end
^^^^^^^^^^^^^^^
Module "B" defines an unsafe value, "value" .
|}]
module rec M: sig val f: unit -> int end = struct let f () = N.x end
and N:sig val x: int end = struct let x = M.f () end;;
[%%expect {|
Exception: Undefined_recursive_module ("", 1, 43).
|}]
|