scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Branch singleton variables warnings would be useful

Open triska opened this issue 2 years ago • 2 comments

For instance, in the following program, Z is a branch singleton variable: In every branch it occurs, it occurs only once.

p(X) :-
        (   true ->
            X = Z
        ;   X = Z
        ).

A warning about such branch singleton variables would be useful. Currently, we get no warning at all, because Z is not a singleton variable since it occurs more than once in the clause.

triska avatar Nov 30 '23 20:11 triska

Does only (;)/2 predicate introduce branches? Or something else can too? I think lambdas can be tricky...

hurufu avatar Oct 07 '24 19:10 hurufu

(;)/2 is no doubt the context in which such a mistake is most likely to be encountered and would be most useful to detect.

triska avatar Oct 07 '24 19:10 triska