"Unreachable case" pattern matching with an Option of List #197
-
Hello, I've started to play with Iron to learn more about refinement types, but I've encountered an error that I cannot understand the cause. When I pattern match on an Option of List like object UnreachableCodeExample {
def example(): Unit =
// Using List: Compile error: Unreachable case
val optionList: Option[List[Int] :| ForAll[Greater[1]]] =
List(2, 3).refineOption
optionList match
case Some(value) => ??? // Compile error: Unreachable case
case None => ???
// Using Seq: Everything work
val optionSeq: Option[Seq[Int] :| ForAll[Greater[1]]] =
Seq(2, 3).refineOption
optionSeq match
case Some(value) => ??? // No compile error
case None => ???
// Using Set: Everything work
val optionSet: Option[Set[Int] :| ForAll[Greater[1]]] =
Set(2, 3).refineOption
optionSet match
case Some(value) => ??? // No compile error
case None => ???
} What do you think I am missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello. Can you send the full error message? IIRC the compiler gives additional information about why the case is unreachable. |
Beta Was this translation helpful? Give feedback.
It is indeed a compiler bug. I opened an issue with a minimal example: scala/scala3#19275