[m-rev.] for review: make --warn-unused-imports more effective

Zoltan Somogyi zoltan.somogyi at runbox.com
Fri Nov 28 16:19:48 AEDT 2025



On Fri, 28 Nov 2025 14:18:44 +1100, Julien Fischer <jfischer at opturion.com> wrote:
> Actually, there is one problem here.  The compiler is now ignoring the
> --no-warn-interface-imports
> option and always printing a warning.

Ok. The issue here is that we have TWO options that both seem to want
to control whether this warnings is enabled:

optdb(oc_warn_dodgy_mod, warn_unused_interface_imports, bool(yes),
    % Not documented because its relationship with --warn-unused-imports
    % is too complicated for users (and maybe even developers ...).
    priv_help("warn-unused-interface-imports", [
        w("Warn about modules that are imported in the interface"),
        w("but not used there.")])).
optdb(oc_warn_dodgy_mod, warn_interface_imports,       bool(yes),
    help("warn-interface-imports", [
        w("Do not warn about modules imported in the interface,"),
        w("but which are not used in the interface.")])).

The code that my diff modified

- used warn_interface_imports to control whether we ran the code
  that looked for unused interface imports, but then

- used warn_unused_interface_imports, the other option, as the
  option that controlled whether any generated warnings would
  actually be printed.

I saw the difference as a silent bug, and "fixed" it by making
the first step use warn_unused_interface_imports as well.

I am not sure whether this difference was ever intentional, and
I don't plan to find out, because it does not matter. The duplication
NOW is a problem, as you found out. These two options should
clearly be merged, and to minimize disruption, it should be reachable
by both its old names. The only question is: which is the name
we should put first, i.e. which one's use should we encourage?

I vote for --warn-unused-interface-imports, both because it better
describes what it does, and because it has a more obvious connection
to its bigger brother --warn-unused-imports. Any other votes?

OTOH, I think the help text for --warn-interface-imports above
is clearly the one we should use.

Zoltan.


More information about the reviews mailing list