Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Module type of allows to transform a malformed module type into a vicious signature, breaking soundness #7851
Original bug ID: 7851
By removing some equations from the type of a module (using nondep_subtyping for instance), one can make it malformed. Then by further abstracting in with "module type of", and instantiating with "with type", it is possible to break soundness.
Discovered during #2051
Steps to reproduce
type (,) eq = Eq : ('a,'a) eq
Comment author: @lpw25
Just for clarity, the example without functor application or GADTs:
module F(X : sig type t end) = struct
module M = F(struct type t end);;
module type S = module type of M;;
module rec M1 : S with type x = int and type y = bool = M1;;
let bool_of_int x =
Comment author: @garrigue
Indeed I expected this comment, which is very true. Unfortunately, as long as we do not drop completely the compatibility mode, the problem will stay around.
Thanks for the example without GADTs. Since we're just relying on the local equality, there is indeed no need for them, meaning that this bug is in OCaml at least since the introduction of module type of (which I think came after module rec, but I may have the order wrong).
This is really the kind of situation where a post-checker, such as Pierrick Couderc's, would come handy.