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

unhelpful syntax error when inferred lambda parameters mismatch expected count #18657

Closed
odersky opened this issue Oct 6, 2023 · 0 comments · Fixed by #18665
Closed

unhelpful syntax error when inferred lambda parameters mismatch expected count #18657

odersky opened this issue Oct 6, 2023 · 0 comments · Fixed by #18665
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:enhancement

Comments

@odersky
Copy link
Contributor

odersky commented Oct 6, 2023

Compiler version

3.3.1

Minimized example

val f: (Int, Int) => Int = Integer.compare(_ + 1, _)

Output Error/Warning message

-- [E086] Syntax Error: --------------------------------------------------------
1 |val f: (Int, Int) => Int = Integer.compare(_ + 1, _)
  |                           ^^^^^^^^^^^^^^^^^^^^^^^^^
  |                           Wrong number of parameters, expected: 2
1 error found

Why this Error/Warning was not helpful

The error message is correct, but I must work hard to realise that actually the first argument to Integer.compare is expanded to a separate nested lambda, so the placeholder is not for f.

Suggested improvement

The error could be improved by an explanation. Under -explain I would like to see:

  • The full expected type
  • The eta expanded argument

This would make it clear which parameter each placeholder refers to.

@odersky odersky added stat:needs triage Every issue needs to have an "area" and "itype" label area:reporting Error reporting including formatting, implicit suggestions, etc and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 6, 2023
odersky added a commit to dotty-staging/dotty that referenced this issue Oct 7, 2023
@bishabosha bishabosha added itype:enhancement better-errors Issues concerned with improving confusing/unhelpful diagnostic messages labels Oct 10, 2023
@bishabosha bishabosha changed the title Improve error message unhelpful syntax error when inferred lambda parameters mismatch expected count Oct 10, 2023
WojciechMazur pushed a commit that referenced this issue Jun 22, 2024
WojciechMazur pushed a commit that referenced this issue Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants