diff options
author | Thomas Refis <thomas.refis@gmail.com> | 2021-05-10 11:58:41 +0200 |
---|---|---|
committer | Thomas Refis <thomas.refis@gmail.com> | 2021-05-10 11:58:41 +0200 |
commit | fae4bbc0a41525a81416016a3e4a26a416475b4a (patch) | |
tree | 75f038c7dcf8e356139633bc6b26f2e4157ef84f /typing/typemod.ml | |
parent | 49528a69449dbd24551dea1f152490e3b67742d3 (diff) | |
download | ocaml-fae4bbc0a41525a81416016a3e4a26a416475b4a.tar.gz |
update locations for destructive substitutions
Diffstat (limited to 'typing/typemod.ml')
-rw-r--r-- | typing/typemod.ml | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/typing/typemod.ml b/typing/typemod.ml index 682004e216..db060bd404 100644 --- a/typing/typemod.ml +++ b/typing/typemod.ml @@ -691,24 +691,27 @@ let merge_constraint initial_env loc sg lid constr = With_cannot_remove_constrained_type)); fun s path -> Subst.add_type_function path ~params ~body s in - let sub = List.fold_left how_to_extend_subst Subst.identity !real_ids in + let sub = Subst.change_locs Subst.identity loc in + let sub = List.fold_left how_to_extend_subst sub !real_ids in (* This signature will not be used directly, it will always be freshened by the caller. So what we do with the scope doesn't really matter. But making it local makes it unlikely that we will ever use the result of this function unfreshened without issue. *) Subst.signature Make_local sub sg | (_, _, Twith_modsubst (real_path, _)) -> + let sub = Subst.change_locs Subst.identity loc in let sub = List.fold_left (fun s path -> Subst.add_module_path path real_path s) - Subst.identity + sub !real_ids in (* See explanation in the [Twith_typesubst] case above. *) Subst.signature Make_local sub sg | (_, _, Twith_modtypesubst tmty) -> let add s p = Subst.add_modtype_path p tmty.mty_type s in - let sub = List.fold_left add Subst.identity !real_ids in + let sub = Subst.change_locs Subst.identity loc in + let sub = List.fold_left add sub !real_ids in Subst.signature Make_local sub sg | _ -> sg |