Skip to content

pattern matching with given and vararg fails #21742

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

Closed
sjbiaga opened this issue Oct 9, 2024 · 0 comments · Fixed by #21748
Closed

pattern matching with given and vararg fails #21742

sjbiaga opened this issue Oct 9, 2024 · 0 comments · Fixed by #21748
Assignees
Milestone

Comments

@sjbiaga
Copy link

sjbiaga commented Oct 9, 2024

Compiler version

3.5.2-RC1

Minimized example

case  class C(n: Int, ds: Double*)
def m(using n: Int)  = n+1
C(1, 2, 3, 4) match { case C(given Int, ds*)  => m }

Output Error/Warning message

1 |C(1, 2, 3, 4) match { case C(given Int, ds*) => m }
  |                                                 ^
  |No given instance of type Int was found for parameter n of method m
  |
  |Note: given instance given_Int was not considered because it was not imported with `import given`.
1 error found

Suggested improvement

Just as if the vararg parameter were a Seq .

case  class C(n: Int, ds: Seq[Double])
def m(using n: Int)  = n+1
C(1, Seq(2, 3, 4)) match { case C(given Int, ds)  => m }
@sjbiaga sjbiaga added area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:enhancement stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 9, 2024
@dwijnand dwijnand self-assigned this Oct 10, 2024
@dwijnand dwijnand added itype:bug area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label itype:enhancement area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages labels Oct 10, 2024
@WojciechMazur WojciechMazur added this to the 3.6.3 milestone Dec 9, 2024
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.

3 participants