[m-rev.] Compiler bug in conjunction with modes

Volker Wysk post at volker-wysk.de
Thu Nov 9 05:04:04 AEDT 2023


Am Donnerstag, dem 09.11.2023 um 04:53 +1100 schrieb Zoltan Somogyi:
> On 2023-11-09 04:15 +11:00 AEDT, "Volker Wysk" <post at volker-wysk.de> wrote:
> > I think I found a compiler bug.
> 
> What you found is not a compiler bug. It is a bug in your own code.
> 
> > finally.m:027: In clause for `with_connection((pred(out, di, uo) is det),
> > out,
> > finally.m:027:   di, uo)':
> > finally.m:027:   in call to predicate `exception.finally'/6:
> > finally.m:027:   mode error: arguments
> > finally.m:027:   `Pred, PRes, Cleanup, _CleanupRes, STATE_VARIABLE_IO_0,
> > STATE_VARIABLE_IO'
> > finally.m:027:   have the following insts:
> > finally.m:027:     (pred(out, di, uo) is det),
> > finally.m:027:     free,
> > finally.m:027:     /* unique */ (pred(out, di, uo) is cc_multi),
> > finally.m:027:     free,
> > finally.m:027:     unique,
> > finally.m:027:     free
> > finally.m:027:   which does not match any of the modes for predicate
> > finally.m:027:   `exception.finally'/6.
> > 
> > 
> > It says that the inst of the !:IO argument is free. That's wrong, isn't it?
> 
> Why would it be wrong? The initial insts of a di/uo pair of arguments
> are unique/free, as in this case.
> 
> The bug in your code is the inconsistency between the determinisms
> of the Pred and Cleanup arguments: Pred is det, while Cleanup is cc_multi.
> exception.finally has two modes: one required both to be det, while
> the other requires both to be cc_multi. This is the bug in your code,
> which the compiler is correctly reporting.
> 
> In the future, can you please be more cautious before claiming
> that the compiler cannot possibly be right when it reports an error?

Sorry. I'll do my best.  :-(

Volker


More information about the reviews mailing list