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
Seemingly unrelated and spurious error (unaliasable module) with value shadowing #7818
Comments
Comment author: mandrykin Added another shorter reproduction case with another inconsistency: while the first functor is accepted, it's not possible to specify its (the same) output signature explicitly. |
Comment author: @lpw25 This is a symptom of a bug that I already knew about but never got around to fixing (or reporting). Basically, the check that is supposed to stop you making aliases to functor parameters is very broken. IIRC there are at least 3 ways to work around it -- and you have stumbled onto one of them here. I hadn't realised this could cause actual problems, but it seems that it can cause module inclusion checks to fail as in this case (although there is no explicit coercion the presence of repeated values causes an inclusion check between the module type with two I was already planning to try and remove the restriction on aliases to functor parameters for 4.08, which would fix this bug as a side-effect. |
Comment author: mandrykin So would you recommend currently to better avoid those aliases (to functor arguments) even when they are accepted e.g. by using (* ... module Id : sig type t end ... *) module Make3 (T' : Termsig.Term.S) = struct (so that there are just type equalities instead of module aliases)? Module aliases are inferred by default even if the resulting signature doesn't contain them, so e.g. module Make3 (T' : Termsig.Term.S) : sig end = struct also fails, but they can be avoided if prevented earlier (upon include). |
Comment author: @lpw25 Yeah, that's probably your best bet for now. |
Comment author: @garrigue Wouldn't it be reasonable to fix this bug (i.e. correctly detect non-aliasable modules)? |
Comment author: @garrigue Actually this doesn't seem to be the one. There are many calls to strengthen... |
Comment author: @garrigue By the way, this is clearly a soundness bug. Using cannot_alias2.ml, we have: module M = Make1 (struct module Term0 = struct module Id = struct let x = "a" end end module T = Term0 end);;module M : sig module Id : sig val x : string end module Id2 = Id end M.Id.x;;Segmentation fault |
Comment author: @garrigue I have opened #1898 Leo, if you know other ways to break Env.is_functor_arg, please speak up because this is a bad problem. Comment: I thought originally that Env.is_functor_arg was safe, because all accesses to the contents of the argument should use a path which starts from it. Unfortunately, copying components of a submodule of the argument seem to lose this connection, allowing to use aliases coming from inside the argument. Properly tracking this seems complex, hence this somehow radical approach. |
Original bug ID: 7818
Reporter: mandrykin
Assigned to: @garrigue
Status: resolved (set by @garrigue on 2018-09-21T06:19:36Z)
Resolution: fixed
Priority: high
Severity: crash
Platform: x86_64 SMP
OS: Linux 4.4.0
OS Version: Ubuntu 16.04.4
Version: 4.06.1
Target version: 4.07.1+dev/rc1
Fixed in version: 4.07.1+dev/rc1
Category: typing
Monitored by: @nojb @Drup
Bug description
module Termsig = struct
end;;
module Make (T' : Termsig.Term.S) = struct
end;;
Gives:
Error: Signature mismatch:
Modules do not match:
sig
module Id = T'.Term0.Id
module Id2 = Id
val u : int
val u : int
end
is not included in
sig module Id = T'.Term0.Id module Id2 = Id val u : int end
In module Id:
Module T'.Term0.Id cannot be aliased
While after removing the rebinding of
u
:module Make (T' : Termsig.Term.S) = struct
end;;
is accepted as well as
module Make (T' : Termsig.Term.S) = struct
end;;
(so the module aliasing seems not to be related).
The real cause of the error is too confusing to me to try to explain it more clearly in the summary.
File attachments
The text was updated successfully, but these errors were encountered: