What's the semantics of implicit open when shadowing

The implicit open Stdlib is done early to make it possible to shadow Stdlib’s submodule with user defined one.

The construction of the initial environment is done in essentially five steps:

  1. start with the predefined environment
  2. add the persistent modules from the standard library
  3. open the Stdlib module
  4. add the persistent modules from all other directories in the path (from the -I option)
  5. open the initially opened modules provided by the -open flag

(see https://github.com/ocaml/ocaml/pull/9345#issuecomment-613463446 for some recent discussion).
which means that all included directory -I dir_k have already been added to the path when the -open M_l flags are handled.

2 Likes