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: 6427 Reporter:@yallop Assigned to:@garrigue Status: closed (set by @xavierleroy on 2015-12-11T18:27:05Z) Resolution: fixed Priority: normal Severity: minor Version: 4.02.0+dev Fixed in version: 4.02.0+dev Category: typing
Bug description
Leo and I encountered the following problem in the 4.02.0 branch today:
$ cat bug.ml
let flag = ref false
module F(S : sig module type T end) (A : S.T) (B : S.T) =
struct
module X = (val if !flag then (module A) else (module B) : S.T)
end
module type S = sig type t val x : t end
module Float = struct type t = float let x = 0.0 end
module Int = struct type t = int let x = 0 end
This is a clever way to insert an abstract type in a signature...
How did you find it?
Mtype.contains_type was already checking for abstract module
type definitions, and for unresolved module types, but strangely
ignored this case (probably assumed a bad analogy with type
abbreviations).
Thanks for the quick fix! This one came up while investigating the boundaries of the module system rather than in a real program. Leo was teaching me how modules work, and I was trying to understand exactly what makes it impossible to write a module with the following type:
module False : functor (S : sig module type T end) -> S.T
Original bug ID: 6427
Reporter: @yallop
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:27:05Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.0+dev
Fixed in version: 4.02.0+dev
Category: typing
Bug description
Leo and I encountered the following problem in the 4.02.0 branch today:
$ cat bug.ml
let flag = ref false
module F(S : sig module type T end) (A : S.T) (B : S.T) =
struct
module X = (val if !flag then (module A) else (module B) : S.T)
end
module type S = sig type t val x : t end
module Float = struct type t = float let x = 0.0 end
module Int = struct type t = int let x = 0 end
module M = F(struct module type T = S end)
let () = flag := false
module M1 = M(Float)(Int)
let () = flag := true
module M2 = M(Float)(Int)
let _ = [| M2.X.x; M1.X.x |]
$ ocaml bug.ml
Segmentation fault (core dumped)
The text was updated successfully, but these errors were encountered: