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

Ask did you mean only for accessible members. #17067

Closed
som-snytt opened this issue Mar 7, 2023 · 1 comment · Fixed by #18747
Closed

Ask did you mean only for accessible members. #17067

som-snytt opened this issue Mar 7, 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:bug

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.3.1-RC1-bin-SNAPSHOT-git-6ad22aa

Minimized code

Welcome to Scala 3.3.1-RC1-bin-SNAPSHOT-git-6ad22aa (19, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> "123".view.reverse.padTo(5, '0').iterator.reverse
-- [E008] Not Found Error: ---------------------------------------------------------------------------------------------
1 |"123".view.reverse.padTo(5, '0').iterator.reverse
  |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |value reverse is not a member of Iterator[Char] - did you mean Iterator[Char].reversed?
1 error found

scala> "123".view.reverse.padTo(5, '0').iterator.reversed
-- [E173] Reference Error: ---------------------------------------------------------------------------------------------
1 |"123".view.reverse.padTo(5, '0').iterator.reversed
  |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |method reversed in trait IterableOnceOps cannot be accessed as a member of Iterator[Char] from module class rs$line$1$.
  | Access to protected method reversed not permitted because enclosing object rs$line$1
  | is not a subclass of trait IterableOnceOps in package scala.collection where target is defined
1 error found

Output

As shown.

Expectation

No suggestion of reversed, as in Scala 2.

The Scala 2 backport of "did you mean...?" includes further improvements which are worth forward porting.

scala/scala#10262

Welcome to Scala 2.13.11-20230306-152152-44c6006 (OpenJDK 64-Bit Server VM, Java 19).
Type in expressions for evaluation. Or try :help.

scala> "123".view.reverse.padTo(5, '0').iterator.reverse
                                                 ^
       error: value reverse is not a member of Iterator[Char]

scala> "123".view.reverse.padTo(5, '0').it
                                        ^
       error: value it is not a member of scala.collection.View[Char]
       did you mean init or wait? or perhaps inits or tail?

where further suggestions are at a farther edit distance.

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 7, 2023
@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 8, 2023
@dwijnand
Copy link
Member

dwijnand commented Mar 8, 2023

Should we (and does Scala 2) just blanket disregard protected/private, or are we able to show them when in a scope within which they're accessible? Reminds me of the scala-internals thread linked in #4228.

@som-snytt som-snytt added the better-errors Issues concerned with improving confusing/unhelpful diagnostic messages label Oct 12, 2023
odersky added a commit to dotty-staging/dotty that referenced this issue Oct 23, 2023
 1. Only show accessible members
 2. Show several alternatives if they are at same distance. Unlike Scala 2,
    we do not show alternatives at larger distance. I fear that would produce
    more noise than signal.

Fixes scala#17067
WojciechMazur pushed a commit that referenced this issue Jun 22, 2024
 1. Only show accessible members
 2. Show several alternatives if they are at same distance. Unlike Scala 2,
    we do not show alternatives at larger distance. I fear that would produce
    more noise than signal.

Fixes #17067

[Cherry-picked 5ce1ac9]
WojciechMazur pushed a commit that referenced this issue Jun 23, 2024
 1. Only show accessible members
 2. Show several alternatives if they are at same distance. Unlike Scala 2,
    we do not show alternatives at larger distance. I fear that would produce
    more noise than signal.

Fixes #17067

[Cherry-picked 5ce1ac9]
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:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants