Skip to content
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

Assertion failure in Env.add_gadt_instances #7214

Closed
vicuna opened this issue Apr 6, 2016 · 3 comments
Closed

Assertion failure in Env.add_gadt_instances #7214

vicuna opened this issue Apr 6, 2016 · 3 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Apr 6, 2016

Original bug ID: 7214
Reporter: @stedolan
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-09-24T15:32:14Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Monitored by: braibant @gasche @yallop @hcarty

Bug description

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)
end in
()

Tested on recent trunk and 4.03+beta1.

@vicuna
Copy link
Author

vicuna commented Apr 8, 2016

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.

@vicuna
Copy link
Author

vicuna commented Apr 8, 2016

Comment author: @stedolan

Great!

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
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.

@vicuna
Copy link
Author

vicuna commented Apr 8, 2016

Comment author: @garrigue

Thanks. I added this to the test suite, which is the best way to be safe for the future.

@vicuna vicuna closed this as completed Sep 24, 2017
@vicuna vicuna added the typing label Mar 14, 2019
@vicuna vicuna added this to the 4.03.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants