[m-users.] Determinism error caused by instantiation error, not sure why.

Sean Charles (emacstheviking) objitsu at gmail.com
Mon Oct 31 18:55:18 AEDT 2022


I wish I had your eyes Zoltan!
Yes, it's obvious now but not so late last night!

Thank you!


> On 30 Oct 2022, at 23:17, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
> 
> 
> 2022-10-31 10:11 GMT+11:00 "Sean Charles (emacstheviking)" <objitsu at gmail.com <mailto:objitsu at gmail.com>>:
>> The error:
>> 
>> repl.m:738: In `take_gencall'(in, out, in, out, in, out):
>> repl.m:738:   error: determinism declaration not satisfied.
>> repl.m:738:   Declared `det', inferred `semidet'.
>> repl.m:747: In clause for `take_gencall(in, out, in, out, in, out)':
>> repl.m:747:   warning: unification of `Out' and maybe.yes cannot succeed.
>> repl.m:747:   `Out' has instantiatedness `unique(no)'.
>> 
>> The code:
>> 
>> :- pred take_gencall(error_msg::in, maybe(snode)::out, s::in, s::out,
>>    lsnode::in, lsnode::out) is det.
>> 
>> take_gencall(Er, Out, !S) -->
>>    ( if no_errors(!.S) then
>>        ( if [GC] then
>>            { Pos = snpos(GC) },
>>            ( if { GC = gencall(_, _, _) } then
>>                 { Out = yes(GC) }   <== line 747
>>            else
>>                cerror(Pos, Er, !S),
>>                { Out = no }
>>            )
>>        else
>>            premature(!S)),
>>            { Out = no }
>>    else
>>        { Out = no }
>>    ).
>> 
>> For the life of me I don't understand why the line in bold is causing an error, why has Out become `unique(no)` and does that no refer to a general no or is it the no from the may() discriminated union, I just don't see my mistake. Sorry.
> 
> Because the code you are looking at is not what the compiler sees.
> 
> You have a misplaced close parenthesis. It *should* be just before the final "else",
> but in actuality, it occurs just after "premature(!S)". So what the compiler sees
> is a conjunction containing both (a) the code after the call to premature,
> which is Out = no, and the if-then-else containing Out = yes(GC).
> 
> Zoltan.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20221031/c5b88c54/attachment.html>


More information about the users mailing list