[m-users.] Confused my det/multi error message, full disjunction of type in place.

Zoltan Somogyi zoltan.somogyi at runbox.com
Sun Dec 4 21:48:13 AEDT 2022



On Sun, 4 Dec 2022 10:35:46 +0000, "Sean Charles (emacstheviking)" <objitsu at gmail.com> wrote:
> formatter.m:059: In `write_'(in, out, in, di, uo):
> formatter.m:059:   error: determinism declaration not satisfied.
> formatter.m:059:   Declared `det', inferred `multi'.
> formatter.m:059:   The reason for the difference is the following.
> formatter.m:061:   Inside the case nl/0 of the switch on HeadVar__3:
> formatter.m:061:   disjunction has multiple clauses with solutions.

This error tells you that the code for the nl case is a disjunction.
Since there is only one disjunctionless clause for nl in the code snippet
in your email, this means that you have *another* clause for nl
that you did not include in your email. Before determinism analysis,
the compiler transforms such disjunctions into a switch on the third
argument of write_, which will have a disjunction in the case arm
for nl.

> formatter.m:062: In clause for `write_(in, out, in, di, uo)':
> formatter.m:062:   in argument 1 of call to predicate `io.nl'/2:
> formatter.m:062:   mode error: variable `STATE_VARIABLE_IO_0' has
> formatter.m:062:   instantiatedness `mostly_unique',
> formatter.m:062:   expected instantiatedness was `unique'.
> formatter.m:062:   This kind of uniqueness mismatch is usually caused by doing
> formatter.m:062:   input/output or some other kind of destructive update in a
> formatter.m:062:   context where it can be backtracked over, such as the
> formatter.m:062:   condition of an if-then-else.
> and the full predicate code, I've highlighted the offending clause in bold:
>  
> And the code, I just don't understand, as usual, what the compiler is trying to tell me.
> The io.nl/2 is det, so that can't fail, and presumably the field update can't fail either.

Yes, neither io.nl nor the field update can fail. What this message is telling you
is that *to get to the second disjunct for nl*, execution would have to backtrack *past*
the call to io.nl, which cannot be done, since the execution of io.nl destroys
the initial state of the world.

> And why hasn't this error been raised on all the other cases?

Presumably because they don't have a duplicate clause for them.

Zoltan.


More information about the users mailing list