Skip to content

Poor suggested method reporting in the presence of overloads #19958

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
lihaoyi opened this issue Mar 16, 2024 · 1 comment · Fixed by #19975
Closed

Poor suggested method reporting in the presence of overloads #19958

lihaoyi opened this issue Mar 16, 2024 · 1 comment · Fixed by #19975
Assignees
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:enhancement
Milestone

Comments

@lihaoyi
Copy link
Contributor

lihaoyi commented Mar 16, 2024

Compiler version

3.4.0

Minimized example

val b = new Object().unit

Output Error/Warning message

[info] compiling 1 Scala source to /Users/lihaoyi/test/out/compile.dest/classes ...
[error] -- [E008] Not Found Error: /Users/lihaoyi/test/src/Main.scala:1:21 -------------
[error] 1 |val b = new Object().unit
[error]   |        ^^^^^^^^^^^^^^^^^
[error]   |value unit is not a member of Object - did you mean Object.wait? or perhaps Object.wait or Object.wait?

Why this Error/Warning was not helpful

The message was unhelpful because we repeat Object.wait three times, presumably because there are three overloaded methods wait that have similar names as .unit. This is useless, because those three overloads have the same name, and so displaying that name once is sufficient

Suggested improvement

It should just say

value unit is not a member of Object - did you mean Object.wait?
@lihaoyi lihaoyi 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 Mar 16, 2024
@som-snytt
Copy link
Contributor

Just to check

Welcome to Scala 2.13.13 (OpenJDK 64-Bit Server VM, Java 21.0.2).
Type in expressions for evaluation. Or try :help.

scala> new Object().unit
                    ^
       error: value unit is not a member of Object
       did you mean wait?

scala>

Maybe dotty meant to say

scala> new Object().unit
-- [E008] Not Found Error: ---------------------------------------------------------------------------------------------
1 |new Object().unit
  |^^^^^^^^^^^^^^^^^
  |value unit is not a member of Object - did you mean Object.wait?
  |wait, wait, don't tell me!

@Gedochao Gedochao removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Mar 18, 2024
@odersky odersky self-assigned this Mar 18, 2024
odersky added a commit to dotty-staging/dotty that referenced this issue Mar 18, 2024
hamzaremmal added a commit that referenced this issue Mar 19, 2024
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
WojciechMazur pushed a commit that referenced this issue Jul 3, 2024
WojciechMazur pushed a commit that referenced this issue Jul 3, 2024
WojciechMazur pushed a commit that referenced this issue Jul 3, 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.

5 participants