Re: singleton variable in branch ?
Jan Wielemaker <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 03/01/2014 09:27 AM, Jochem Liem wrote: > The singleton is in the second branch (subsynset). Adding a '_' makes > the warning go away. > > subsynset(Sub, Super) :- > s(I,_,Sub,Kind,_,_), > ( > hyp(I, J) -> > s(J,_,Hyp,Kind,_,_), > Hyp = Super > ; > subsynset(_Hyp, Super) > ). YIP. For your understanding, a `singleton in a branch' is a variable that is syntactically not a singleton (appears in multiple places in the term), but does not transfer a binding from one goal-argument to another. That turns it in to `a semantic singleton'. If anyone has better wording for this warning, please share it. Do take them seriously; in my experience well over half of them indicate real bugs. Cheers --- Jan > > - Jochem > > On Sat, Mar 1, 2014 at 9:37 AM, Carlo Capelli <[email protected]> wrote: >> I get a warning in very simple code - Singleton variable in branch: Hyp >> >> and I can't spot from where the problem arise. >> >> >> subsynset(Sub, Super) :- >> >> s(I,_,Sub,Kind,_,_), >> >> ( hyp(I, J) -> s(J,_,Hyp,Kind,_,_), Hyp = Super >> >> ; subsynset(Hyp, Super) ). >> >> >> >> I tried to swap the Hyp binding - just to see if the warning goes away - >> without luck >> >> >> ... >> >> -> s(J,_,Hyp,Kind,_,_), Hyp = Super >> >> ... >> >> >> Seems that Hyp is present on both branches. Maybe I'm missing some >> execution path ? Any hint about ? >> >> >> Thanks Carlo >> -------------- next part -------------- >> HTML attachment scrubbed and removed >> _______________________________________________ >> SWI-Prolog mailing list >> [email protected] >> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog > > >