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

Spurious exhaustiveness warning on boolean nested in tuple

    Details

      Description

      The warning in the following is unnecessary:

      Welcome to Scala version 2.10.0-20120629-080700-cd1e6f94e9
      [...]
      
      def x(in: (Int, Boolean)) = in match { case (i: Int, b: Boolean) => 3 }
      <console>:7: warning: match may not be exhaustive.
      It would fail on the following inputs: (_, false), (_, true)
             def x(in: (Int, Boolean)) = in match { case (i: Int, b: Boolean) => 3 }
                                         ^
      

      There is no warning if the Int is ignored or bound without an explicit type:

      scala> def x(in: (Int, Boolean)) = in match { case (_, b: Boolean) => 3 }
      x: (in: (Int, Boolean))Int
      

      Keeping the explicit type for the Int but dropping the one for Boolean presents a spurious warning again:

      scala> def x(in: (Int, Boolean)) = in match { case (i: Int, b) => 3 }
      <console>:7: warning: match may not be exhaustive.
      It would fail on the following input: (_, _)
             def x(in: (Int, Boolean)) = in match { case (i: Int, b) => 3 }
                                         ^
      
      scala> x((3,true))
      res2: Int = 3
      

        Activity

        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/824
        Hide
        Mark Harrah added a comment -

        Thank you.

        Show
        Mark Harrah added a comment - Thank you.
        Hide
        Adriaan Moors added a comment -

        thank you for reporting

        Show
        Adriaan Moors added a comment - thank you for reporting

          People

          • Assignee:
            Adriaan Moors
            Reporter:
            Mark Harrah
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development