Closed dsheets closed 10 years ago
I think that this is as it should be. Extensions can be added to types from other modules. For example,
module M : sig
type t = ..
end
module N : sig
type M.t += C
end
You can't refer to C
as N.t.C
because N.t
does not exist (and it does not specify which t
you mean). You can't refer to C
as M.t.C
because the type is open so their could be many C
s in t
and you don't know where they might be.
Right, but being a child of the signature isn't correct, either. For instance:
module M : sig
type t = ..
type u = ..
type t += C
type u += C
end
These constructors are distinct but don't have unique paths. What is required is the ability to refer to one path in the context of another. For your example, C
is something like N#M.t.C
or N~M.t.C
.
Yes, but that example no longer works on trunk (for almost this exact reason), so by 4.03
this will not be a problem.
Oh? I thought
module M : sig
type t = ..
type t += C
end
type M.t += C
and
type t = ..
type t += C
type t += C
were being disallowed.
No it is having multiple extensions with the same name in the same module (regardless of which type they extend) that is being disallowed. This means your original example, and your second new example, but not your first new example.
Note that it is not generally possible to disallow your second new example and allow your original example, because it is not in general possible to know that two types are distinct.
Normal variant constructor identifiers are children of their type.