Skip to content

Commit e9fa3ed

Browse files
authored
do not inject global open into the file being globally opened (#6483)
1 parent accf738 commit e9fa3ed

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

jscomp/core/js_implementation.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let after_parsing_sig ppf outputprefix ast =
6464
else
6565
let modulename = module_of_filename outputprefix in
6666
Lam_compile_env.reset ();
67-
let initial_env = Res_compmisc.initial_env () in
67+
let initial_env = Res_compmisc.initial_env ~modulename () in
6868
Env.set_unit_name modulename;
6969
let tsg = Typemod.transl_signature initial_env ast in
7070
if !Clflags.dump_typedtree then
@@ -149,7 +149,7 @@ let after_parsing_impl ppf outputprefix (ast : Parsetree.structure) =
149149
else
150150
let modulename = Ext_filename.module_name outputprefix in
151151
Lam_compile_env.reset ();
152-
let env = Res_compmisc.initial_env () in
152+
let env = Res_compmisc.initial_env ~modulename () in
153153
Env.set_unit_name modulename;
154154
let typedtree, coercion, _, _ =
155155
Typemod.type_implementation_more

jscomp/core/res_compmisc.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ let open_implicit_module m env =
4141
in
4242
snd (Typemod.type_open_ Override env lid.loc lid)
4343

44-
let initial_env () =
44+
let initial_env ?(modulename) () =
4545
Ident.reinit ();
46+
let open_modules = (match modulename with
47+
| None -> !Clflags.open_modules
48+
| Some modulename ->
49+
!Clflags.open_modules |> List.filter(fun m -> m <> modulename)
50+
) in
4651
let initial = Env.initial_safe_string in
4752
let env =
4853
if !Clflags.nopervasives then initial
@@ -51,4 +56,4 @@ let initial_env () =
5156
List.fold_left
5257
(fun env m -> open_implicit_module m env)
5358
env
54-
(List.rev !Clflags.open_modules)
59+
(List.rev open_modules)

jscomp/core/res_compmisc.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424

2525
val init_path : unit -> unit
2626

27-
val initial_env : unit -> Env.t
27+
val initial_env : ?modulename : string -> unit -> Env.t

0 commit comments

Comments
 (0)