rascal icon indicating copy to clipboard operation
rascal copied to clipboard

false positive of "Arguments of || should introduce same variables"

Open jurgenvinju opened this issue 4 years ago • 4 comments

Describe the bug

This reports:

Arguments of || should introduce same variables, right argument does not introduce key

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 introduce i

if (int i := 1, [i,j] := [1,2] || int j := 2) {
  println("matches");
}

jurgenvinju avatar Jun 04 '21 08:06 jurgenvinju

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 ?

jurgenvinju avatar Mar 18 '22 16:03 jurgenvinju

See https://github.com/usethesource/rascal/pull/1503

jurgenvinju avatar Mar 18 '22 16:03 jurgenvinju

@jurgenvinju No chance, it has been waiting for so long because this is a difficult fix

PaulKlint avatar Mar 18 '22 16:03 PaulKlint

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 :-)

jurgenvinju avatar Mar 19 '22 08:03 jurgenvinju

This is similar to #1515. All depends on the scoping of the operands of ||. Tricky business!

PaulKlint avatar Mar 17 '24 23:03 PaulKlint

Thanks for reporting. Indeed the handling of || was incorrect and resulted in false positives like the one above. Fixed.

PaulKlint avatar Mar 19 '24 14:03 PaulKlint