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
A typing equality is lost in 4.03 branch compared to 4.02.3 #7152
Comments
Comment author: bobot Of course it should be read |
Comment author: bobot The fact that |
Comment author: @garrigue That's indeed bad, For some reason, the first component of the path is dropped. Here is a simpler version. type 'a t
module type S = sig
module Data: sig type t end
val key: Data.t t
end
module Register (D:S) = struct end
module M = struct
module Data = struct type t = int end
let key : _ t = Obj.magic ()
end
module EM = Register(M);; Which gives the meaningless answer:
|
Comment author: @garrigue Fix in 4.03 and trunk by commits 05922fa and 35f10d6. I'm not 100% clear of why it worked before, because non-generalized variables inside submodules have always been strange. |
Comment author: @garrigue Copied from #7313: It took me a while, but here is what this PR is about. module Dem : sig
module Data : sig type t = make_dec end
val key : '_a Fast.t
end You should instantiate '_a by either Data.t or Dem.Data.t, depending on whether you are looking at the type from inside Dem or outside Dem. Since the variable is shared between the two, actually both are invalid. So the solution to #7152 solved this by forcing the expansion, and instantiating by make_dec, which is correct. But this also means that you cannot instantiate such a non-generalizable type variable by an internal abstract type (except when you are coercing before adding the module definition to the environment, since the locking is only done afterward). I understand that all this kind of worked until 4.02.3, but my feeling is that this was purely by chance. Something like lazyness allowing one to instantiate with an internal reference before the exporting substitution occurs, so that the internal-external conflict is avoided. The cause this started to fail is probably a change in evaluation order somewhere, but I'm not sure it's worth tracking it down, because it is bound to be fragile. Just to give you an idea of how the original approach was fragile, it was sufficient to add the line let _ = Dem.key just after the definition of Dem above to break it in all versions up to 4.02. The more restrictive approch implemented here fixes it once and for all, but introduces some regressions, as seen in #7313. |
Original bug ID: 7152
Reporter: bobot
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-09-24T15:33:20Z)
Resolution: fixed
Priority: normal
Severity: major
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Related to: #6752 #7313
Monitored by: @hcarty
Bug description
The file variable.ml compile with 4.02.3 but not with 4.02.3.
I'm not able to minimize it more (except in fact the label can be removed...).
File attachments
The text was updated successfully, but these errors were encountered: