rascal
rascal copied to clipboard
false positive of "Arguments of || should introduce same variables"
Describe the bug
This reports:
Arguments of
||should introduce same variables, right argument does not introducekey
However, key is not introduced by the left side of ||, it was bound earlier:
if (key <- params, [*_,label(key, sym),*_] := kwTypes || sym := \value())) {
println("bla");
}
To Reproduce
Simpler situation to test. Produces the same error:
Arguments of
||should introduce same variables, right argument does not introducei
if (int i := 1, [i,j] := [1,2] || int j := 2) {
println("matches");
}
I'd like this fixed because there is a new standard library module that depends on it waiting to be merged. Is it something I could try myself @PaulKlint ?
See https://github.com/usethesource/rascal/pull/1503
@jurgenvinju No chance, it has been waiting for so long because this is a difficult fix
If we'd add the explicit operator for equality checking in a pattern match, wouldn't this become a lot easier? Maybe it's time we move forward on that anyway. Got bitten by a sneak equality again last week :-)
This is similar to #1515. All depends on the scoping of the operands of ||. Tricky business!
Thanks for reporting. Indeed the handling of || was incorrect and resulted in false positives like the one above. Fixed.