<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">I didn't think I had to as it was intended to be semidetached and fail if neither of the first two matched but I guess, given the syntax as documented, I need to put the final else and a { fail } in.<div><br></div><div>I blame it on all the chemicals.......</div><div><br></div><div>Thanks Volker. Sigh....<br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On 28 Oct 2023, at 11:36, Volker Wysk <post@volker-wysk.de> wrote:</div><br class="Apple-interchange-newline"><div><div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div>Hi</div><div><br></div><div>You don't have an "else" for your second "if".</div><div><br></div><div>Volker</div><div><br></div><div>Am Samstag, dem 28.10.2023 um 11:27 +0100 schrieb Sean Charles (emacstheviking):</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>I have an error I don't quite understand, here is the code, it's a simple DCG type predicate to check that either the next token is a class name or an s-expression containing just a class name and a superclass name,</div><div><font face="APL385"><br></font></div><div><div><font face="Edlo"> 380 :- pred get_class_superclass(</font></div><div><font face="Edlo"> 381 ps::out, maybe(ps)::out, sr_stack::in, sr_stack::out</font></div><div><font face="Edlo"> 382 ) is semidet.</font></div><div><font face="Edlo"> 383</font></div><div><font face="Edlo"> 384 get_class_superclass(Class, Super) --></font></div><div><font face="Edlo"> 385 ( if [ tk(Cp, Cb) ] then {</font></div><div><font face="Edlo"> 386 Class = ps(Cp, Cb),</font></div><div><font face="Edlo"> 387 Super = no</font></div><div><font face="Edlo"> 388 }</font></div><div><font face="Edlo"> 389 else if [ sexp(_, [ tk(Cp, Cb), tk(Sp, Sb) ]) ] then {</font></div><div><font face="Edlo"> 390 Class = ps(Cp, Cb),</font></div><div><font face="Edlo"> 391 Super = yes(ps(Sp, Sb))</font></div><div><font face="Edlo"> 392 } ).</font></div></div><div><br></div><div>and the error message:</div><div><br></div><div><div><font face="Edlo">Making Mercury/cs/shred.c</font></div><div><font face="Edlo">shred.m:389: In clause for `get_class_superclass(out, out, in, out)':</font></div><div><font face="Edlo">shred.m:389: mode mismatch in if-then-else.</font></div><div><font face="Edlo">shred.m:389: The variable `Class' is ground in some branches but not others.</font></div><div><font face="Edlo">shred.m:389: In this branch, `Class' is free.</font></div><div><font face="Edlo">shred.m:389: In this branch, `Class' is ground.</font></div><div><font face="Edlo">shred.m:389: The variable `Super' is ground in some branches but not others.</font></div><div><font face="Edlo">shred.m:389: In this branch, `Super' is free.</font></div><div><font face="Edlo">shred.m:389: In this branch, `Super' is ground.</font></div><div><font face="Edlo">** Error making `Mercury/cs/shred.c'.</font></div><div><font face="Edlo">make: *** [felt] Error 1</font></div></div><div><br></div><div>How can a variable be both free and ground at the same time?</div><div>Is it the if/else-if and it being a semidet predicate?</div><div><br></div><div>Not sure!</div><div>Thanks,</div><div>Sean</div><div><br></div><pre>_______________________________________________</pre><pre>users mailing list</pre><pre><a href="mailto:users@lists.mercurylang.org">users@lists.mercurylang.org</a></pre><pre><a href="https://lists.mercurylang.org/listinfo/users">https://lists.mercurylang.org/listinfo/users</a></pre></blockquote><div><br></div><div><span></span></div></div>
</div></blockquote></div><br></div></body></html>