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
For-comprehension on Either.RightProjection with Tuple2 extractor in generator fails to compile #5589
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5589?orig=1 |
@paulp said: class A {
// First three compile.
def f1(x: Either[Int, String]) = x.right map (y => y)
def f2(x: Either[Int, String]) = for (y <- x.right) yield y
def f3(x: Either[Int, (String, Int)]) = x.right map { case (y1, y2) => (y1, y2) }
// Last one fails.
def f4(x: Either[Int, (String, Int)]) = for ((y1, y2) <- x.right) yield ((y1, y2))
/**
./a.scala:5: error: constructor cannot be instantiated to expected type;
found : (T1, T2)
required: Either[Nothing,(String, Int)]
def f4(x: Either[Int, (String, Int)]) = for ((y1, y2) <- x.right) yield ((y1, y2))
^
./a.scala:5: error: not found: value y1
def f4(x: Either[Int, (String, Int)]) = for ((y1, y2) <- x.right) yield ((y1, y2))
^
./a.scala:5: error: not found: value y2
def f4(x: Either[Int, (String, Int)]) = for ((y1, y2) <- x.right) yield ((y1, y2))
^
three errors found
**/
} |
@paulp said: |
@retronym said: |
scala/scala#1893 wasn't merged, so I thought this was fixed, but it still fails in 2.12.1 with a different error:
Ultimately, However, desugaring this using
I think that's the same error as the original error (#5589 (comment)). I suspect #10285 applied there too, but haven't checked all the facts. |
@Blaisorblade Unfortunately this seems to be a difference in how much down the error path the compiler is going. @paulp's minified code:
in 2.10.4 produces:
which has a version of your
Interestingly, if we alter
With the right-biased Either in 2.12, we can do the same thing without the
This isn't a great solution, since the following fail:
but should give some insight into the shape of this bug |
The for-comprehension in the attempt method fails to compile, despite the fact that the nearly-equivalent desugared version works fine.
I'm guessing it has something to do with filter, since that's one thing that's missing from my desugared version.
The text was updated successfully, but these errors were encountered: