You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 7068 Reporter: lavi Status: closed (set by @xavierleroy on 2017-02-16T14:18:22Z) Resolution: not a bug Priority: normal Severity: major Version: 4.02.3 Target version: 4.03.0+dev / +beta1 Category: ~DO NOT USE (was: OCaml general) Monitored by:@gasche
Note: if the program is compiled with the -rectypes option, ill-founded recursive definitions of the form let rec x = lazy x or let rec x = lazy(lazy(...(lazy x))) are accepted by the type-checker and lead, when forced, to ill-formed values that trigger infinite loops in the garbage collector and other parts of the run-time system. Without the -rectypes option, such ill-founded recursive definitions are rejected by the type-checker.
The last sentence is over optimistic:
module rec A : sig
type t = B.t Lazy.t
val x : t
end = struct
type t = B.t Lazy.t
let x = lazy B.x
end and B : sig
type t
val x : t
end = struct
type t = A.t
let x = A.x
end
let y = Lazy.force A.x
The text was updated successfully, but these errors were encountered:
I personnaly do not have, but I would say the same with -rectypes. My point is only that using recursive modules allows to build the same values (with inner abstract type) than with -rectypes.
My point is only that using recursive modules allows to build the same values with inner abstract type) than with -rectypes.
This is correct, but rather harmless in my opinion. The purpose of -rectypes is not so much to restrict cyclic data structures (you can always do "let rec x = 1 :: x") but to prohibit cyclic types, which can lead to extremely mysterious inferred types and type errors.
I'm closing this PR as requiring no immediate action.
Original bug ID: 7068
Reporter: lavi
Status: closed (set by @xavierleroy on 2017-02-16T14:18:22Z)
Resolution: not a bug
Priority: normal
Severity: major
Version: 4.02.3
Target version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @gasche
Bug description
Manual http://caml.inria.fr/pub/docs/manual-ocaml-4.02/libref/Lazy.html says:
Note: if the program is compiled with the -rectypes option, ill-founded recursive definitions of the form let rec x = lazy x or let rec x = lazy(lazy(...(lazy x))) are accepted by the type-checker and lead, when forced, to ill-formed values that trigger infinite loops in the garbage collector and other parts of the run-time system. Without the -rectypes option, such ill-founded recursive definitions are rejected by the type-checker.
The last sentence is over optimistic:
module rec A : sig
type t = B.t Lazy.t
val x : t
end = struct
type t = B.t Lazy.t
let x = lazy B.x
end and B : sig
type t
val x : t
end = struct
type t = A.t
let x = A.x
end
let y = Lazy.force A.x
The text was updated successfully, but these errors were encountered: