New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module type of allows to transform a malformed module type into a vicious signature, breaking soundness #7851
Comments
Comment author: @garrigue While this is a soundness issue, one really has to go through all these steps to trigger it, so it is not that urgent. |
Comment author: @lpw25 I think this would be fixed if |
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 = bool_of_int 3;; |
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. |
…r recursive modules
…r recursive modules
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
Since the bug is fixed, let's close this; we can find it again if another problem arises. |
Original bug ID: 7851
Reporter: @garrigue
Assigned to: @garrigue
Status: assigned (set by @garrigue on 2018-09-20T06:37:44Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.07.0
Target version: 4.08.0+dev/beta1/beta2
Category: typing
Monitored by: @nojb @gasche @yallop @yakobowski
Bug description
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
module F(X : Set.OrderedType) = struct
type x = Set.Make(X).t and y = Set.Make(X).t
type t = E of (x,x) eq
type u = t = E of (x,y) eq
end;;
module M = F(struct type t let compare = compare end);;
module type S = module type of M;;
module rec M1 : S with type x = int and type y = bool = M1;;
let (E eq : M1.u) = (E Eq : M1.t);;
let cast : type a b. (a,b) eq -> a -> b = fun Eq x -> x;;
cast eq 3;;
The text was updated successfully, but these errors were encountered: