-
Notifications
You must be signed in to change notification settings - Fork 1.1k
"case" function literal incorrectly desugared #873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That's certainly not as specified. I don't know what scalac does here. But val xs = List(1, 2, 3).zipWithIndex xs.map{ (case (x, y) => x + y } And the translation is x$1: (Int, Int) => x$1 match ... So it seems scalac does some conversion according to the expected type. I
should work. But the example you gave should not work. Can you file another On Tue, Oct 27, 2015 at 3:12 AM, Guillaume Martres <[email protected]
Martin Odersky |
So that would be the inverse of what scalac is doing, since object Test {
def call(k: (Int, Int) => Int): Unit = ???
def test = call({
case (1, 2) => 1
case (a, b) => a + b
})
} Do you think we could have a nicer way of expressing this in dotty than: def test = call((_, _) match {
case (1, 2) => 1
case (a, b) => a + b
}) ? |
Maybe ask on the scala gitter. As far as I can see this is a bug in scalac. Cheers
On Tue, Oct 27, 2015 at 5:09 PM, Guillaume Martres <[email protected]
Martin Odersky |
at https://gitter.im/scala/contributors?at=56332776196bdeec543b9ac3 @odersky writes "It is specified in Sec. 8.5 of the Spec. So, it’s a feature, not a bug, after all" |
This fails with:
Because
{ case (x, y) => ()}
is expanded tox$1 => x$1 match { case (x, y) => ()}
, instead it should be expanded to(x$1, x$2) => (x$1, x$2) match { case (x, y) => ()}
(like in Scala 2) because this compiles fine in Dotty:The text was updated successfully, but these errors were encountered: