-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
withFilter required for irrefutable for comprehension pattern #15579
Comments
Minification: //> using scala "3.nightly"
//> using option "-source:future"
trait Foo[A]:
def map[B](f: A => B): Foo[B] = ???
def baz: Foo[(Int, String)] = ???
@main def main =
for (x, y) <- baz
yield ()
|
This code has failed the same way since 3.0.0 |
Are you sure? //> using scala "3.1.3"
//> using option "-source:future"
trait Foo[A]:
def map[B](f: A => B): Foo[B] = ???
def baz: Foo[(Int, String)] = ???
@main def main =
for (x, y) <- baz
yield ()
Apologies if I did something dumb here :) Edit: even works in 3.0.0.
|
when I tried in the repl: ~/workspace/scripts » scala
Welcome to Scala 3.1.3 (17.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> trait Foo[A]:
| def map[B](f: A => B): Foo[B] = ???
|
| def baz: Foo[(Int, String)] = ???
|
| @main def main =
| for (x, y) <- baz
| yield ()
|
-- [E008] Not Found Error: -----------------------------------------------------
7 | for (x, y) <- baz
| ^^^
| value withFilter is not a member of Foo[(Int, String)]
1 error found
scala> Edit: ok sorry, I did not see you used the |
so it seems that |
same issue with a non-tuple pattern: //> using scala "3.2.0-RC1"
trait Foo[A]:
def map[B](f: A => B): Foo[B] = ???
final case class Bar[A, B](a: A, b: B)
def baz: Foo[Bar[Int, String]] = ???
@main def main =
for Bar(x, y) <- baz
yield ()
|
Should we classify this issue as a regression then? On the one hand this stopped working, on the other the semantics of |
I think the issue is that these patterns should not be considered refutable |
😳 PR: #15593 Thanks for testing the RC and catching this! |
Tuple decomposition seems to have regressed in some cases. The following works fine under 3.1.3
Compiler version
3.2.0-RC1
Minimized code
Output
Expectation
Compilation passes
The text was updated successfully, but these errors were encountered: