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

Julien Fischer jfischer at opturion.com
Sat Nov 29 01:24:30 AEDT 2025


On Fri, 28 Nov 2025 at 23:15, Zoltan Somogyi <zoltan.somogyi at runbox.com>
wrote:

 > Merge --warn-interface-imports into --warn-unused-interface-imports.

...

> diff --git a/NEWS.md b/NEWS.md
> index 1cf3dbb0a..b0ae3b257 100644
> --- a/NEWS.md
> +++ b/NEWS.md
> @@ -1637,6 +1637,12 @@ Changes to the Mercury compiler
>    The compiler still accepts the old names, but we intend to remove them
>    after the next stable release.
>
> +* We have changed the preferred name of the --warn-interface-imports
option
> +  to --warn-unused-interface-imports, which is more descriptive.

Quote the option names using backticks.

...

> diff --git a/compiler/module_qual.m b/compiler/module_qual.m
> index 9c202dd7f..2222c943f 100644
> --- a/compiler/module_qual.m
> +++ b/compiler/module_qual.m
> @@ -53,18 +53,18 @@
>  %
>  % For the same reason (we don't know what modules predicate names,
>  % function names and function symbols in goals may refer to), this
package
> -% cannot implement any equivalent of --warn-interface-imports that would
> +% cannot implement any equivalent of --warn-unused-interface-imports
that would
>  % report unnecessary imports in the *implementation* section of a module.
>  %
>  % If the --warn-unused-imports option is set, then unused_imports.m
> -% can generate all the warnings we would, but it can generate *better*
> -% messages, since unlike the code here, it can report that an imported
module
> -% is unused *anywhere* in the module. However, even if
--warn-unused-imports
> -% *is* set, the code in unused_imports.m won't be invoked if we stop
> -% compilation before its normal invocation time, due to e.g. type or more
> -% errors. What we should do is generate warnings here; print them if we
> -% stop before the unused_imports pass; throw them away if we *do* get to
> -% that pass. We don't (yet) do this.
> +% can generate all the warnings we would, but it can generate *more*
messages,
> +% since unlike the code here, it can report that an imported module is
unused
> +% *anywhere* in the module. However, even if --warn-unused-imports *is*
set,
> +% the code in unused_imports.m won't be invoked if we stop compilation
> +% before its normal invocation time, due to e.g. type or more

Did you mean mode errors there?

> +% errors. We therefore print warnings about unneeded imports in the
interface
> +% section only if the option controlling its operation dictates that
> +% the code in unused_imports.m won't be invoked.
>  %
>
 %---------------------------------------------------------------------------%

That looks fine otherwise.

Julien.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20251129/b2cd09d2/attachment.html>


More information about the reviews mailing list