Aladdin - Scala Bugtracking
[#1261] project: compiler priority: low category: bug
submitter assigned to status date submitted
Iulian Burak fixed 2007-08-08 10:40:25.0
subject [contrib #730] Strange "unreachable code" error with match expression
code
sealed trait Elem
case class Foo extends Elem
case class Bar extends Elem
trait Row extends Elem
object Row {
  def unapply(r: Row) = true
}
    
def f(elem: Elem) {
  elem match {
    case Bar() => 
    case Row() =>
    case Foo() => // ERROR: unreachable code
  }
}

If Row is changed to a case class or the unapply parameter type to Elem, it compiles.

The error depends on whether and where the Row case is inserted. The above seems to be the only permutation that does not compile. The following, e.g., compiles:

def f(elem: Elem) {
  elem match {
    case Row() =>    
    case Bar() => 
    case Foo() =>
  }
}
what happened
Compile error.
what expected Successful compilation.
[back to overview]
Changes of this bug report
Iulian  edited on  2007-08-08 10:40:37.0
Burak  edited on  2007-08-14 18:06:20.0