summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testsuite/tests/typing-modules/aliases.ml6
-rw-r--r--testsuite/tests/typing-modules/aliases.ml.reference4
-rw-r--r--typing/typemod.ml3
3 files changed, 12 insertions, 1 deletions
diff --git a/testsuite/tests/typing-modules/aliases.ml b/testsuite/tests/typing-modules/aliases.ml
index 0b7e7ae2b..8c8bad340 100644
--- a/testsuite/tests/typing-modules/aliases.ml
+++ b/testsuite/tests/typing-modules/aliases.ml
@@ -192,3 +192,9 @@ module M = struct
end
end;;
module type S = module type of M ;;
+
+(* PR#6365 *)
+module type S = sig module M : sig type t val x : t end end;;
+module H = struct type t = A let x = A end;;
+module H' = H;;
+module type S' = S with module M = H';; (* shouldn't introduce an alias *)
diff --git a/testsuite/tests/typing-modules/aliases.ml.reference b/testsuite/tests/typing-modules/aliases.ml.reference
index 730252b58..a024731ab 100644
--- a/testsuite/tests/typing-modules/aliases.ml.reference
+++ b/testsuite/tests/typing-modules/aliases.ml.reference
@@ -347,4 +347,8 @@ Error: In this `with' constraint, the new definition of I
module Q :
sig type wrap' = wrap = W of (Set.Make(Int).t, Set.Make(N.I).t) eq end
end
+# module type S = sig module M : sig type t val x : t end end
+# module H : sig type t = A val x : t end
+# module H' = H
+# module type S' = sig module M : sig type t = H.t = A val x : t end end
#
diff --git a/typing/typemod.ml b/typing/typemod.ml
index 1e7a38019..72dbe7074 100644
--- a/typing/typemod.ml
+++ b/typing/typemod.ml
@@ -198,7 +198,8 @@ let merge_constraint initial_env loc sg constr =
when Ident.name id = s ->
let path = Typetexp.find_module initial_env loc lid.txt in
let md' = Env.find_module path env in
- let newmd = Mtype.strengthen_decl env md' path in
+ let md'' = {md' with md_type = Mtype.remove_aliases env md'.md_type} in
+ let newmd = Mtype.strengthen_decl env md'' path in
ignore(Includemod.modtypes env newmd.md_type md.md_type);
(Pident id, lid, Twith_module (path, lid)),
Sig_module(id, newmd, rs) :: rem