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

Can we have "did you mean..." for top-level names rather than just methods #18682

Closed
lihaoyi opened this issue Oct 12, 2023 · 1 comment · Fixed by #18747
Closed

Can we have "did you mean..." for top-level names rather than just methods #18682

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

Comments

@lihaoyi
Copy link
Contributor

lihaoyi commented Oct 12, 2023

Compiler version

3.3.1

Minimized example

Mis-typing a method results in a nice suggestion, presumably using Levenshtein distance or something:

Screenshot 2023-10-12 at 10 51 10 PM

But mis-typing a free variable name doesn't:

Screenshot 2023-10-12 at 10 50 48 PM

Could we make mis-typed top level names give nice suggestions too? Presumably we already know everything that is in scope, and can do a Levenshtein distance comparison to find any that look close enough to suggest

@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 Oct 12, 2023
@bishabosha bishabosha removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Oct 12, 2023
@som-snytt
Copy link
Contributor

The related converse issue at #17067

Scala 2 reminder it's not just top-level scala/bug#12023

scala> val hello = "hi"; hellx
-- [E006] Not Found Error: ---------------------------------------------------------------------------------------------
1 |val hello = "hi"; hellx
  |                  ^^^^^
  |                  Not found: hellx
  |
  | longer explanation available when compiling with `-explain`
1 error found

scala> val hello = "hi"; this.hellx
-- [E008] Not Found Error: ---------------------------------------------------------------------------------------------
1 |val hello = "hi"; this.hellx
  |                  ^^^^^^^^^^
  |                value hellx is not a member of object rs$line$1 - did you mean (rs$line$1 : rs$line$1.type).hello?
1 error found

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.

4 participants