Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nested Tuple>22 pattern becomes refutable #16657

Closed
bishabosha opened this issue Jan 11, 2023 · 0 comments · Fixed by #19212
Closed

nested Tuple>22 pattern becomes refutable #16657

bishabosha opened this issue Jan 11, 2023 · 0 comments · Fixed by #19212

Comments

@bishabosha
Copy link
Member

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)
@bishabosha bishabosha added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label area:pattern-matching area:tuples and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 11, 2023
@Kordyjan Kordyjan modified the milestones: Future versions, 3.3.1-RC1 Jan 13, 2023
@Kordyjan Kordyjan modified the milestones: 3.3.1-RC1, 3.3.2-RC1 Mar 13, 2023
@Kordyjan Kordyjan modified the milestones: 3.3.2, Future versions Aug 9, 2023
@dwijnand dwijnand linked a pull request Dec 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants