Desugaring of for with pattern match and if guard

It’s explained as a bug.

It should have the same behavior as:

for case (x: B) <- s if x.b yield x

where the extra parens say, “I am a pattern.” More precisely, it signals, “I am refutable.”

Without case, the parens matter:

  for x: B <- s if x.b yield x // B => Boolean
  for (x: B) <- s if x.b yield x // pattern's type B is more specialized...

But I don’t think parens should matter with case, which always takes a refutable pattern and always filters.

I don’t see a unit test for “parenless case", so I assume it’s a bug.

4 Likes