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

Julien Fischer jfischer at opturion.com
Sun Feb 15 15:49:17 AEDT 2026


On Sun, 15 Feb 2026 at 12:36, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
>
>
>
> On Sun, 15 Feb 2026 01:18:19 +1100, Julien Fischer <jfischer at opturion.com> w

> > > --- a/tests/invalid_nodepend/bigtest.err_exp
> > > +++ b/tests/invalid_nodepend/bigtest.err_exp
> > > @@ -21,5 +21,6 @@ bigtest.m:010: Syntax error at token ':-': operator precedence error.
> > >  bigtest.m:013: Error:  [38;5;87m`incorrect_declaration' [39;49m is  [38;5;203mnot a valid declaration type. [39;49m
> > >  bigtest.m:015: Error: predicate  [38;5;87m`p'/1 [39;49m  [38;5;203mhas no mode declaration. [39;49m
> > >  bigtest.m:015:   (Use `--infer-modes' to enable mode inference.)
> > > +bigtest.m:025: Warning: type constructor `t2'/0 is  [38;5;203munused. [39;49m
> >
> > Given that this test lacks module, interface and implementation declarations,
> > I'm not sure you can say that t2/0 is a local type or not.
>
> That module tests mostly a grab-bag of proposed-then-quickly-forgotten
> additions to the Mercury language, such as undiscriminated union types.
> I don't think it is useful anymore (if it *ever* was useful), but it doesn't
> hurt much either.

It does date from 1994.  I think it still has some small value: what happens
if you put a fragment of Prolog into the Mercury compiler?

Aside: the start of the errors for that file are:

bigtest.m:005: Error: module must start with a `:- module' declaration.
bigtest.m:005: Error: module `bigtest' should start with either an
bigtest.m:005:   `:- interface' declaration or an `:- implementation'
bigtest.m:005:   declaration.
bigtest.m:005:   The following assumes that the missing declaration is an
bigtest.m:005:   `:- implementation' declaration.

If I were being picky, there's ambiguity as to what declaration the
module should
start with: is it module (first message) or interface / implementation
(second message)?

> > > +    --no-warn-unused-types
> > > +        Warn about types that are neither used in their defining module nor
> > > +        exported to other modules.
> >
> > I don't think this should be enabled by default. Most of the other warnings
> > for unused things are off by default. I can see this being slightly annoying
> > if I am trying to sketch out a module's types before writing the code that
> > uses them.
>
> Agreed, though I think that after bootstrapping, we *should* add it
> to STANDARD_MCFLAGS.

Of course.

> > The diff looks fine otherwise.
>
> Thanks. I followed all your other suggestions. The updated diff is
> attached.

That looks fine.

Julien.


More information about the reviews mailing list