Skip to content

Follow-up hints for DYM? #18762

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
som-snytt opened this issue Oct 25, 2023 · 5 comments
Closed

Follow-up hints for DYM? #18762

som-snytt opened this issue Oct 25, 2023 · 5 comments
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.4.0-RC1-bin-SNAPSHOT-git-8046a8b

Minimized code

Welcome to Scala 3.4.0-RC1-bin-SNAPSHOT-git-8046a8b (21, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> "xyz".lengt  // duplicate suggestion
-- [E008] Not Found Error: ---------------------------------------------------------------------------------------------
1 |"xyz".lengt
  |^^^^^^^^^^^
  |value lengt is not a member of String - did you mean ("xyz" : String).length? or perhaps ("xyz" : String).length?
1 error found

scala> "xyz".lgnet  // should notice word scramble
-- [E008] Not Found Error: ---------------------------------------------------------------------------------------------
1 |"xyz".lgnet
  |^^^^^^^^^^^
  |value lgnet is not a member of String - did you mean ("xyz" : String).lines?
1 error found

from test

-- [E008] Not Found Error: test/files/neg/suggest-similar.scala:16:25 --------------------------------------------------
16 |  import scala.io.StdIn.{readline, readInt}
   |                         ^^^^^^^^
   |value readline is not a member of object scala.io.StdIn - did you mean StdIn.readLine? or perhaps StdIn.readLine?

// compare

suggest-similar.scala:16: error: value readline is not a member of object scala.io.StdIn
did you mean readLine? or perhaps readByte, readInt, or readLong?
  import scala.io.StdIn.{readline, readInt}
         ^

// but dotty is probably trimming the suggestions by length; maybe scala 2 admits too much;
// and scala 2 should not suggest `readInt`, which is already in the clause

another example where "word scramble" trumps edit length limits, dotty does not suggest abc for acb:

suggest-similar.scala:54: error: value acb is not a member of example.assignments.C
did you mean abc?
  def f = c.acb(42)
            ^

Dotty suggests x for y because y_= is 3 chars:

59 |  def v = c y_= 1
   |          ^^^^^
   |          value y_= is not a member of example.assignments.C - did you mean c.x_=? or perhaps c.z_=?

Output

As shown.

Expectation

No duplicate suggestion.

Taking "word scrambles" (all letters present but badly garbled by twitchy fingers) seems like a win.

Ignoring suffixes of setters seems like a win for the mutable crowd.

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 25, 2023
@som-snytt
Copy link
Contributor Author

Not sure if the proper label is "linting" or "hinting". Probably a good Spree candidate!

@som-snytt
Copy link
Contributor Author

31 |val _ = bar.ool // error
   |        ^^^^^^^
   |        value ool is not a member of object Bar - did you mean bar.cool? or perhaps bar.pool or bar.wool?

All suggestions are equally valid.

Scala 2 is agnostic:

+i18682.scala:36: error: value ool is not a member of object Bar
+did you mean cool, pool, or wool?
+  val _ = bar.ool // error
+              ^

@bishabosha bishabosha added area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:enhancement itype:bug and removed stat:needs triage Every issue needs to have an "area" and "itype" label itype:bug itype:enhancement labels Oct 26, 2023
@odersky
Copy link
Contributor

odersky commented Oct 26, 2023

I agree it is important. But I think I'll leave this to others to improve further.

My strategy is: when in doubt, it's better to hint less than more. So missing an "obvious" candidate is less problematic than suggesting improbably ones.

That's why I am less concerned about missed word scramble, but duplicates are certainly a problem. Also, we should not
print ("xyz" : String).length. "xyz".length is what we need here.

@odersky odersky removed their assignment Oct 26, 2023
@odersky odersky added the Spree Suitable for a future Spree label Oct 26, 2023
@som-snytt
Copy link
Contributor Author

If Spree doesn't take it, I will. Also, I was comparing while preparing to backport the Dotty improvements. Thanks again for being a trailblazer! (Only mildly poking fun, the improvement is modest by some measure, but makes a real difference.)

I also enjoy the new rubric, "linting and hinting".

@odersky
Copy link
Contributor

odersky commented Oct 27, 2023

I think Scala Spree has probably lots of other puzzlers to solve, so it's all yours,

@odersky odersky removed the Spree Suitable for a future Spree label Oct 27, 2023
@som-snytt som-snytt removed their assignment Jan 21, 2025
@som-snytt som-snytt closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2025
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

No branches or pull requests

3 participants