Hello, simplified REPL sample (Scastie):
$ scala
Welcome to Scala 2.13.6 (OpenJDK 64-Bit Server VM, Java 1.8.0_302).
Type in expressions for evaluation. Or try :help.
scala> def cond = false
def cond: Boolean
scala> def test = for {
| () <- cond match {
| case true => Some(()) // : Option[Unit]
| case false => Some(Seq((), ())) // : Option[Seq[Unit]]
| }
| } yield ()
def test: Option[Unit]
scala> test
val res0: Option[Unit] = None
This is not yielding any compile error despite the branches of the pattern match having different types. Perhaps even more surprising, the final result is None
despite both branches being Some
. Is this a known behaviour? Seems like a bug to me.