Skip to content

Commit 2f076b0

Browse files
authored
flambda-backend: Iterate over all persistent modules in Env.iter_env (#1962)
Currently, `Env.iter_env` doesn't involve `Persistent_env` unless something in the `Env.t` is bound to a persistent module. This risks missing possibilities for path shortening, since most persistent modules are only stored in `Persistent_env`.
1 parent e466e10 commit 2f076b0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

typing/env.ml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1599,13 +1599,12 @@ let iter_env wrap proj1 proj2 f env () =
15991599
| Mod_unbound _ -> ()
16001600
| Mod_local data ->
16011601
iter_components (Pident id) path data.mda_components
1602-
| Mod_persistent ->
1603-
let modname = modname_of_ident id in
1604-
match Persistent_env.find_in_cache !persistent_env modname with
1605-
| None -> ()
1606-
| Some data ->
1607-
iter_components (Pident id) path data.mda_components)
1608-
env.modules
1602+
| Mod_persistent -> ())
1603+
env.modules;
1604+
Persistent_env.fold !persistent_env (fun name data () ->
1605+
let id = Ident.create_persistent (Compilation_unit.Name.to_string name) in
1606+
let path = Pident id in
1607+
iter_components path path data.mda_components) ()
16091608

16101609
let run_iter_cont l =
16111610
iter_env_cont := [];

0 commit comments

Comments
 (0)