<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 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><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></body></html>