Signature substitutions fail in submodules #5911
Original bug ID: 5911
The following code snippet shows signatures "S" and "T" and two functors "Good" and "Bad":
The functor "Good" substitutes a type in its argument of signature "S" and then accesses a value having this type, proving that the substitution has worked.
The functor "Bad" uses an argument of signature "T", which merely contains a submodule of signature "S", performing the exact same substitution otherwise. This time the substitution fails. Running "ocaml" on this snippet yields:
File "bug.ml", line 13, characters 11-16:
Here is the snippet:
module type S = sig
module Good (X : S with type t := unit) = struct
module type T = sig module M : S end
module Bad (X : T with type M.t := unit) = struct
The text was updated successfully, but these errors were encountered:
Comment author: @garrigue
Actually this is not supposed to work: if you look at the manual, this substitution is only defined for toplevel identifiers. Otherwise, doing a valid substitution gets much more complicated.
Fixed in trunk and 4.00 in revisions 13282 and 13283.
Comment author: @mmottl
Indeed, reading the manual sometimes helps :-)
The error message was quite misleading, especially in contexts with many nested modules and type "t"s. It wasn't clear at first whether I was even referring to the right module. Fixing this at the parser level will surely greatly help. Thanks for the fast fix!