Permalink
Browse files

Fix PR#6376

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14650 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
1 parent 0b097e9 commit 82e2f35a149a35f08a739e9036add39abb20bcbb Jacques Garrigue committed Apr 21, 2014
@@ -198,3 +198,9 @@ 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 *)
+
+(* PR#6376 *)
+module type Alias = sig module N : sig end module M = N end;;
+module F (X : sig end) = struct type t end;;
+module type A = Alias with module N := F(List);;
+module rec Bad : A = Bad;;
@@ -351,4 +351,24 @@ Error: In this `with' constraint, the new definition of I
# 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
+# module type Alias = sig module N : sig end module M = N end
+# module F : functor (X : sig end) -> sig type t end
+# Characters -1--1:
+ module type A = Alias with module N := F(List);;
+
+Error: Module type declarations do not match:
+ module type A = sig module M = F(List) end
+ does not match
+ module type A = sig module M = F(List) end
+ At position module type A = <here>
+ Modules do not match:
+ sig module M = F(List) end
+ is not included in
+ sig module M = F(List) end
+ At position module type A = sig module M : <here> end
+ Module F(List) cannot be aliased
+# Characters 17-18:
+ module rec Bad : A = Bad;;
+ ^
+Error: Unbound module type A
#
View
@@ -36,6 +36,7 @@ type symptom =
Ctype.class_match_failure list
| Unbound_modtype_path of Path.t
| Unbound_module_path of Path.t
+ | Invalid_module_alias of Path.t
type pos =
Module of Ident.t | Modtype of Ident.t | Arg of Ident.t | Body of Ident.t
@@ -190,6 +191,8 @@ let rec modtypes env cxt subst mty1 mty2 =
and try_modtypes env cxt subst mty1 mty2 =
match (mty1, mty2) with
| (Mty_alias p1, Mty_alias p2) ->
+ if Env.is_functor_arg p2 env then
+ raise (Error[cxt, env, Invalid_module_alias p2]);
if Path.same p1 p2 then Tcoerce_none else
let p1 = Env.normalize_path None env p1
and p2 = Env.normalize_path None env (Subst.module_path subst p2) in
@@ -486,6 +489,8 @@ let include_err ppf = function
fprintf ppf "Unbound module type %a" Printtyp.path path
| Unbound_module_path path ->
fprintf ppf "Unbound module %a" Printtyp.path path
+ | Invalid_module_alias path ->
+ fprintf ppf "Module %a cannot be aliased" Printtyp.path path
let rec context ppf = function
Module id :: rem ->
View
@@ -41,6 +41,7 @@ type symptom =
Ctype.class_match_failure list
| Unbound_modtype_path of Path.t
| Unbound_module_path of Path.t
+ | Invalid_module_alias of Path.t
type pos =
Module of Ident.t | Modtype of Ident.t | Arg of Ident.t | Body of Ident.t

0 comments on commit 82e2f35

Please sign in to comment.