Skip to content

Wrong unreachable and exhaustiveness warnings for large tuples #19084

Closed
@odersky

Description

@odersky

Compiler version

3.4.0 RC1

Minimized example

@main def Test =
  val y: (
    Int, Int, Int, Int, Int, Int, Int, Int, Int, Int,
    "Bob", Int, 33, Int,
    Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
     =
      (0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      "Bob", 0, 33, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

  y match
    case b @ (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9,
          "Bob", y1, 33, y2,
          z0, z1, z2, z3, z4, z5, z6, z7, z8, z9)
     => // !!! spurious unreachable case warning
      println(y)
    case _ => assert(false)

Output

-- [E030] Match case Unreachable Warning: ../new/test.scala:12:9 ---------------
12 |    case b @ (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9,
   |         ^
   |         Unreachable case
13 |          "Bob", y1, 33, y2,
14 |          z0, z1, z2, z3, z4, z5, z6, z7, z8, z9)

Expectation

If I run the program it does get into the case and print the correct value.

Variant: If I drop the last case case _ => assert(false), I get this instead:

-- [E029] Pattern Match Exhaustivity Warning: ../new/test.scala:11:2 -----------
11 |  y match
   |  ^
   |match may not be exhaustive.
   |
   |It would fail on pattern case: _: *:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[("Bob" : String),*:[Int,*:[(33 : Int),*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,*:[Int,Tuple$package.EmptyTuple]]]]]]]]]]]]]]]]]]]]]]]]
   |
   | longer explanation available when compiling with `-explain`

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions