Skip to content

Commit

Permalink
Iterate over all persistent modules in Env.iter_env
Browse files Browse the repository at this point in the history
From ocaml-flambda/flambda-backend#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`.
  • Loading branch information
lukemaurer committed Nov 15, 2023
1 parent d1cb680 commit e8100a7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions typing/env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1511,13 +1511,12 @@ let iter_env wrap proj1 proj2 f env () =
| Mod_unbound _ -> ()
| Mod_local data ->
iter_components (Pident id) path data.mda_components
| Mod_persistent ->
let modname = Ident.name id in
match Persistent_env.find_in_cache !persistent_env modname with
| None -> ()
| Some data ->
iter_components (Pident id) path data.mda_components)
env.modules
| Mod_persistent -> ())
env.modules;
Persistent_env.fold !persistent_env (fun name data () ->
let id = Ident.create_persistent name in
let path = Pident id in
iter_components path path data.mda_components) ()

let run_iter_cont l =
iter_env_cont := [];
Expand Down

0 comments on commit e8100a7

Please sign in to comment.