unexpected type error when packing a module alias #6982
Original bug ID: 6982
When building the code below, I get the error:
File "std_internal.ml", line 25, characters 18-25:
As you can see in the test, it only happens when I pack an alias, not if I use the module pointed to by the alias, and not if I force the alias to be expanded. Since the code types when not using an alias, I would expect it to type when using an alias.
Apparently, in Typemod.type_package, the typer rewrites (module Some_alias) into (module let %M = Some_alias in %M), and then complains that %M is free in the package type.
Steps to reproduce
module A = struct
type t = (module A_S)
module type S = sig type t end
let f (type a) (module X : S with type t = a) = ()
let _ = f (module A) (* ok *)
module A_annotated_alias : S with type t = (module A.A_S) = A
let _ = f (module A_annotated_alias) (* ok )
module A_alias = A
let _ = f (module A_alias_expanded : S with type t = (module A.A_S)) (* ok )
let _ = f (module A_alias : S with type t = (module A.A_S)) (* doesn't type )
Comment author: @garrigue
Fixed in trunk at revision 16410.