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

Unclear "... must be called with () argument" error message #17123

Closed
dsbos opened this issue Mar 17, 2023 · 1 comment · Fixed by #17126
Closed

Unclear "... must be called with () argument" error message #17123

dsbos opened this issue Mar 17, 2023 · 1 comment · Fixed by #17126
Assignees
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc
Milestone

Comments

@dsbos
Copy link

dsbos commented Mar 17, 2023

Compiler version

3.2.2

Minimized example

object ConfusingErrorMessage {
  def m()() = ()
  m()
}

Output

.../ConfusingErrorMessage.scala:3:4
method m in object ConfusingErrorMessage must be called with () argument
  m()

Note how the error message says that the method needs to be called with an empty argument list, even though the method is called with an empty argument list.

(Yes, I know that the real problem is that it needs a second empty argument list too, but the error message doesn't say or hint at that, and therefore is confusing.)

Expectation

Better error message wording and/or structure.

Maybe refer to the partial call m() instead of referring to just method m when saying that something must be called with a () argument list.

Maybe say something like "call to m must be called with a(nother) () argument."

Also, report the column number consistently. When the first (empty) argument list is missing, the column number points to where the list is missing (the column after m), but when a second or later (argument) list is missing, the column number points into the middle of the last present argument list, not pointing to where something it missing.

@dsbos dsbos added the stat:needs triage Every issue needs to have an "area" and "itype" label label Mar 17, 2023
@som-snytt
Copy link
Contributor

Scala 2 has the same issue, and also incorrectly predicts what Scala 3 would do.

Related Scala 3 ticket on position (for missing givens) and PR to avoid pointing the caret to outer space.
#15630
#15644

I like a message that shows me what to write, like this related Scala 2 message:

scala> def m(i: Int)(j: Int) = ()
def m(i: Int)(j: Int): Unit

scala> m(42)
        ^
       error: missing argument list for method m
       Unapplied methods are only converted to functions when a function type is expected.
       You can make this conversion explicit by writing `m _` or `m(_)(_)` instead of `m`.

@nicolasstucki nicolasstucki added 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 Mar 17, 2023
@nicolasstucki nicolasstucki self-assigned this Mar 17, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 17, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 17, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 3, 2023
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 3, 2023
Dedelweiss pushed a commit to Dedelweiss/dotty that referenced this issue Apr 17, 2023
@Kordyjan Kordyjan added this to the 3.3.1 milestone Aug 1, 2023
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants