Skip to content

nested Tuple>22 pattern becomes refutable #16657

Closed
@bishabosha

Description

@bishabosha

Compiler version

3.2.1

Minimized code

val (_, (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, c22, _)) = // nested pattern has 23 elems
  (2, (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4))

Output

val c22: Int = 3
-- Warning: --------------------------------------------------------------------
2 |      (2, (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4))
  |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |pattern's type scala.runtime.TupleXXL does not match the right hand side expression's type (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int
  |  , 
  |Int, Int, Int, Int, Int, Int, Int)
  |
  |If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
  |which may result in a MatchError at runtime.

Expectation

No warning, no inference of TupleXXL.

Note:

if the Tuple 23 pattern is at the top level then it is fine:

val (_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, c22, _) =
  (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions