[m-users.] Free and Ground in the same error line?

Volker Wysk post at volker-wysk.de
Sat Oct 28 21:36:14 AEDT 2023


Hi

You don't have an "else" for your second "if".

Volker

Am Samstag, dem 28.10.2023 um 11:27 +0100 schrieb Sean Charles
(emacstheviking):
> 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,
> 
>     380 :- pred get_class_superclass(
>     381     ps::out, maybe(ps)::out, sr_stack::in, sr_stack::out
>     382 ) is semidet.
>     383
>     384 get_class_superclass(Class, Super) -->
>     385     ( if [ tk(Cp, Cb) ] then {
>     386         Class = ps(Cp, Cb),
>     387         Super = no
>     388     }
>     389     else if [ sexp(_, [ tk(Cp, Cb), tk(Sp, Sb) ]) ] then {
>     390         Class = ps(Cp, Cb),
>     391         Super = yes(ps(Sp, Sb))
>     392     } ).
> 
> and the error message:
> 
> Making Mercury/cs/shred.c
> shred.m:389: In clause for `get_class_superclass(out, out, in, out)':
> shred.m:389:   mode mismatch in if-then-else.
> shred.m:389:   The variable `Class' is ground in some branches but not
> others.
> shred.m:389:     In this branch, `Class' is free.
> shred.m:389:     In this branch, `Class' is ground.
> shred.m:389:   The variable `Super' is ground in some branches but not
> others.
> shred.m:389:     In this branch, `Super' is free.
> shred.m:389:     In this branch, `Super' is ground.
> ** Error making `Mercury/cs/shred.c'.
> make: *** [felt] Error 1
> 
> How can a variable be both free and ground at the same time?
> Is it the if/else-if and it being a semidet predicate?
> 
> Not sure!
> Thanks,
> Sean
> 
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users

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


More information about the users mailing list