[m-users.] determinism declaration of main as "erroneous"

Volker Wysk post at volker-wysk.de
Tue Oct 29 23:57:05 AEDT 2019


Am Dienstag, den 29.10.2019, 20:21 +1100 schrieb Julien Fischer:
> On Tue, 29 Oct 2019, Volker Wysk wrote:
> 
> > This program compiles:
> > 
> > :- module test_format.
> > :- interface.
> > :- import_module io.
> > :- pred main(io::di, io::uo) is det.
> > 
> > :- implementation.
> > :- import_module exception, list, string.
> > 
> > main(!IO) :-
> >    throw("bla").
> > 
> > 
> > But I get this warning message:
> > 
> > test_format.m:004: In `main'(di, uo):
> > test_format.m:004:   warning: determinism declaration could be
> > tighter.
> > test_format.m:004:   Declared `det', inferred `erroneous'.
> > 
> > When I replace "det" by "erroneous", I get:
> > 
> > test_format.m:004: Error: `main'/2 must be `det' or `cc_multi'.
> > ** Error making `Mercury/cs/test_format.c'.
> > 
> > So the warning message is wrong. A little bug.
> 
> The warning is just the standard one that determinism analysis
> generates
> for any predicate where the determinism could be tighter.  (That
> warning
> doesn't consider main/2 to be a special case.)  The check implemented
> by
> the error message is specific to main/2.  

That's what I meant to say: the compiler should take into account that
main/2 is a special case.

> The wording of the warning is
> a bit off in this particular case, but the warning still has value;
> in
> most circumstances having a main prediate that is erroneous is likely
> a
> bug.

Hmmm. You can see it like that.

> Speaking of which, why do you have program that does nothing but
> throw
> an exception?  You could always avoid the warning by writing it as:
> 
>      main(!IO) :-
>          ( if semidet_true then
>              throw("bla")
>          else
>              true
>          ).

I was just trying, because of another problem I ran into. I've figured
that one out.


Cheers
Volker



More information about the users mailing list