Created
August 6, 2013 17:07
-
-
Save ms-tg/6166436 to your computer and use it in GitHub Desktop.
From Ratan: desugar a for-comprehension to see why assignment won't work with Either RightProjections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//// | |
// Output of running: | |
// $ scala -Xprint:parser -e "val e: Either[String, Int] = Right(1); for {i <- e.right; j = i + 1} yield j" | |
//// | |
// | |
// Picked up _JAVA_OPTIONS: -Xss3m -XX:MaxPermSize=256M | |
// /tmp/scalacmd2064075741948415763.scala:1: error: value map is not a member | |
// of Product with Either[String,(Int, Int)] with Serializable | |
// val e: Either[String, Int] = Right(1); for {i <- e.right; j = i + 1} yield j | |
// ^ | |
// one error found | |
// [[syntax trees at end of parser]]// Scala source: scalacmd2064075741948415763.scala | |
package <empty> { | |
object Main extends scala.ScalaObject { | |
def <init>() = { | |
super.<init>(); | |
() | |
}; | |
def main(argv: Array[String]): scala.Unit = { | |
val args = argv; | |
{ | |
final class $anon extends scala.AnyRef { | |
def <init>() = { | |
super.<init>(); | |
() | |
}; | |
val e: Either[String, Int] = Right(1); | |
e.right.map(((i) => { | |
val j = i.$plus(1); | |
scala.Tuple2(i, j) | |
})).map(((x$1) => x$1: @scala.unchecked match { | |
case scala.Tuple2((i @ _), (j @ _)) => j | |
})) | |
}; | |
new $anon() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment