[m-rev.] for review: extend --warn-unused-types to eqv types

Julien Fischer jfischer at opturion.com
Sun Mar 8 15:12:06 AEDT 2026


On Sun, 8 Mar 2026 at 02:08, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:

> Warn about unused local equivalence types ...
>
> ... in some contexts.
>
> compiler/unused_types.m:
>     Implement the easy part of the above, the part that happens
>     *after* we collect the info about which equivalence types are used.
>     Document why we can report unused equivalence types only in some contexts.
>
> compiler/prog_data_used_modules.m:
>     Define an extension of the used_modules type that also records
>     which equivalence types were expanded in the module.
>
>     Define the operations we need on this extended type.
>
> compiler/equiv_type.m:
>     Invoke one of those operations to record the expansions of equivalence
>     types, if requested to do so.
>
>     Inline the predicate that used to do this at its only call site.
>
> compiler/hlds_module.m:
>     Replace the used_module field in the module_info with a value of
>     the extended type that includes not just the old used_modules info,
>     but also the set of expanded equivalence types.
>
>     Delete a utility predicate on the old field. The last call to this
>     predicate was deleted on 2022 march 30.
>
> compiler/equiv_type_parse_tree.m:
> compiler/make_hlds_passes.m:
> compiler/mercury_compile_make_hlds.m:
> compiler/unused_imports.m:
>     Conform to the changes above.
>
> tests/warnings/warn_dead_procs.{m,err_exp}:
>     This test case already tests for warnings about unused du types.
>     Extend it to also test for unused eqv types.

...

> diff --git a/compiler/prog_data_used_modules.m b/compiler/prog_data_used_modules.m
> index b4f024143..4d300d188 100644
> --- a/compiler/prog_data_used_modules.m
> +++ b/compiler/prog_data_used_modules.m
> @@ -15,11 +15,21 @@
>
>  :- import_module mdbcomp.
>  :- import_module mdbcomp.sym_name.
> +:- import_module parse_tree.prog_data.
>
>  :- import_module set_tree234.
>
>  %---------------------------------------------------------------------------%
>
> +:- type used_eqv_modules
> +    --->    used_eqv_modules(
> +                % The equivalence types expanded in the interface
> +                % and in implementation.
> +                int_eqv_type_ctors  :: set_tree234(type_ctor),
> +                imp_eqv_type_ctors  :: set_tree234(type_ctor),
> +                all_used_modules    :: used_modules
> +            ).

Add an overall comment describing to that type and its purpose.

The rest looks fine.

Julien.


More information about the reviews mailing list