Skip to content

Give better error when matching too many fields #10757

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
LPTK opened this issue Dec 11, 2020 · 1 comment · Fixed by #13063
Closed

Give better error when matching too many fields #10757

LPTK opened this issue Dec 11, 2020 · 1 comment · Fixed by #13063
Assignees
Labels
area:pattern-matching area:reporting Error reporting including formatting, implicit suggestions, etc help wanted itype:bug
Milestone

Comments

@LPTK
Copy link
Contributor

LPTK commented Dec 11, 2020

I just spent a good amount of time trying to figure out why my code would not compile after a refactoring, because the error message was inadequate.

Minimized example

case class Var(name: String)

@main def f = Var("a") match
  case Var(name, _) => name: String

Output

Found:    (name : Any)
Required: String

Expectation

Too many patterns given in `Var`
@smarter smarter added area:pattern-matching area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug help wanted labels Dec 11, 2020
@dwijnand
Copy link
Member

Scala 2 says:

Var.scala:5: error: wrong number of arguments for pattern Var(name: String)
    case Var(name, _) => name: String
            ^
1 error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:pattern-matching area:reporting Error reporting including formatting, implicit suggestions, etc help wanted itype:bug
Projects
None yet
5 participants