bug icon indicating copy to clipboard operation
bug copied to clipboard

2.13 regression: false negative, missing unreachable warning after extractor returning `Some`

Open SethTisue opened this issue 10 months ago • 1 comments

both Scala 2.12.20 and Scala 3.6.3 give an unreachable warning but Scala 2.13 does not:

trait Tree
object Tree {
  def unapply(tree: Tree): Some[Int] = ???
}
object Test {
  def foo(tree: Tree) =
    tree match {
      case Tree(_) => ???
      case _ => "unreachable"
    }
}

note that adding a case null => ??? line does causes the unreachable warning to emerge

the Scala 3 warning text is helpfully explicit about the status of null:

-- [E121] Pattern Match Warning: -----------------------------------------------
9 |      case _ => "unreachable"
  |           ^
  |Unreachable case except for null (if this is intentional, consider writing case null => instead).

SethTisue avatar Feb 12 '25 03:02 SethTisue

this may be tangled up with tickets such as https://github.com/scala/bug/issues/11457

SethTisue avatar Feb 12 '25 03:02 SethTisue