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?
to your account
Original bug ID: 7214
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-09-24T15:32:14Z)
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Monitored by: braibant @gasche @yallop @hcarty
The following program causes an assertion in Env.add_gadt_instance to fail:
type _ t = I : int t
let f (type a) (x : a t) =
let module M = struct
let (I : a t) = x
let x = (I : a t)
Tested on recent trunk and 4.03+beta1.
The text was updated successfully, but these errors were encountered:
Comment author: @garrigue
Fixed in 4.03 and trunk, commits 24cb12f and 8667b66.
Do not allow refining local abstract types in toplevel lets, as they have a different scope.
Note that we should still think about whether we should allow this eventually, and how.
Sorry, something went wrong.
Comment author: @stedolan
If you do allow this eventually, you'll have to be very careful to avoid the same sort of issues as #7215 arising via "module rec" instead of "let rec".
Here's an erroneous program which used to trigger the assert, and is now correctly rejected. Any patch that allows toplevel refinement will have to ensure this program is still rejected:
type (,) eq = Refl : ('a, 'a) eq
let bad (type a) =
let module N = struct
module rec M : sig
val e : (int, a) eq
end = struct
let (Refl : (int, a) eq) = M.e
let e : (int, a) eq = Refl
end in N.M.e
I do not think that the current check for "recursive module cannot be safely evaluated" will catch this case, for the same reasons as #7215.
Thanks. I added this to the test suite, which is the best way to be safe for the future.
No branches or pull requests