Warning for redundant open M and let open M in #5357
Original bug ID: 5357
GHC has a warning for never used imports; such imports are just redundant and cause unexpected name space contamination. The warning is useful to keep up your import list minimal as possible.
OCaml's open has the same issue of the name space contamination, and unnecessary opens should be warned, too.
And I have added a new warning for it.
You can obtain the latest diff for OCaml 3.12.1 from my repo at https://bitbucket.org/camlspotter/mutated_ocaml , redundant_open_warning branch.
With this patch, I have found nearly 150 redundant opens in OCaml source code!
A global hashtbl and side effects are used to minimize the amount of modifications for easy patching. If we are going to implement this feature in a future OCaml officially, we could make it cleaner.
The text was updated successfully, but these errors were encountered:
Comment author: @garrigue
After reading it, it seems to do something useful in a straightforward way.
My only reservation is the "with_open" type constructor.
Also we should probably remove all unneeded open's from the sources,
I'm for merging, but maybe better to ask on caml-devel first.
Comment author: @alainfrisch
Something I don't understand with the implementation is that "open statements" are identified simply with the opened path. So if we have two opens on the same module, and only one is actually used, the other will not be reported as being unused?