Scala Programming Language
  1. Scala Programming Language
  2. SI-6146

Wrong pattern matching warning message 'unreachable code'

    Details

      Description

      In the following pattern matching scenario, the compiler for Scala 2.10.0-M6 emits the warning message "unreachable code". That warning is not emitted in Scala 2.9.2. Furthermore, a simple test shows the case is still reached correctly.

      trait AxisCompanion {
         sealed trait Format
         object Format {
            case object Decimal extends Format
            case object Integer extends Format
            final case class Time( hours: Boolean = false, millis: Boolean = true ) extends Format
         }
      }
      object Axis extends AxisCompanion
      class Axis {
         import Axis._
         def test( f: Format ) = f match {
            case Format.Integer => "Int"
            case Format.Time( hours, millis ) => "Time"
            case Format.Decimal => "Dec"
         }
      }
      

      The warning:

      <console>:20: warning: unreachable code
                   case Format.Time( hours, millis ) => "Time"                                                ^
      

      A test:

      val a = new Axis
      a.test( Axis.Format.Time() ) // ok!
      

        Issue Links

          Activity

          Show
          Jason Zaugg added a comment - https://github.com/scala/scala/pull/2088
          Hide
          Paul Phillips added a comment -

          After a boatload of difficult pattern matcher, THIS is now my one test failure? Ay caramba. Back into the fray...

          Show
          Paul Phillips added a comment - After a boatload of difficult pattern matcher, THIS is now my one test failure? Ay caramba. Back into the fray...
          Hide
          Jason Zaugg added a comment -

          Let me know if you want me to take a look at how its failing.

          Show
          Jason Zaugg added a comment - Let me know if you want me to take a look at how its failing.
          Hide
          Paul Phillips added a comment -

          It wasn't so bad, I got it.

          Show
          Paul Phillips added a comment - It wasn't so bad, I got it.
          Hide
          Paul Phillips added a comment -

          Thanks though.

          Show
          Paul Phillips added a comment - Thanks though.

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Sciss
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development