diff --git a/typing/mtype.ml b/typing/mtype.ml index 0b4805c14..417697397 100644 --- a/typing/mtype.ml +++ b/typing/mtype.ml @@ -28,6 +28,9 @@ let rec scrape env mty = end | _ -> mty +let freshen mty = + Subst.modtype Subst.identity mty + let rec strengthen env mty p = match scrape env mty with Tmty_signature sg -> diff --git a/typing/mtype.mli b/typing/mtype.mli index ee720be28..abb66b969 100644 --- a/typing/mtype.mli +++ b/typing/mtype.mli @@ -20,6 +20,9 @@ val scrape: Env.t -> module_type -> module_type (* Expand toplevel module type abbreviations till hitting a "hard" module type (signature, functor, or abstract module type ident. *) +val freshen: module_type -> module_type + (* Return an alpha-equivalent copy of the given module type + where bound identifiers are fresh. *) val strengthen: Env.t -> module_type -> Path.t -> module_type (* Strengthen abstract type components relative to the given path. *) diff --git a/typing/typemod.ml b/typing/typemod.ml index 00e87b60e..294f8a005 100644 --- a/typing/typemod.ml +++ b/typing/typemod.ml @@ -237,7 +237,7 @@ let rec transl_modtype env smty = (fun sg (lid, sdecl) -> merge_constraint env smty.pmty_loc sg lid sdecl) init_sg constraints in - Tmty_signature final_sg + Mtype.freshen (Tmty_signature final_sg) and transl_signature env sg = let type_names = ref StringSet.empty