SI-9834 Improve error on failed op=#5454
Conversation
adriaanm
left a comment
There was a problem hiding this comment.
Looks good overall, but I have a few questions after a first pass.
| if (Statistics.canEnable) Statistics.stopTimer(failedApplyNanos, appStart) | ||
| reportError | ||
| val t = reportError | ||
| val Apply(Select(qual2, _), args2) = t |
There was a problem hiding this comment.
val t@Apply(Select(qual2, _), args2) = reportError?
There was a problem hiding this comment.
Check! People think newlines grow on trees. Wait was that a compiler joke? Next time someone asks for a feature, People think syntax grows on trees!
| case SilentResultValue(t) => t | ||
| case err: SilentTypeError => | ||
| val t = reportError | ||
| context.reporter.echo("Expression does not convert to assignment because:") |
There was a problem hiding this comment.
What's the reasoning behind echoing? I'd expect to see context.issue/context.warning?
There was a problem hiding this comment.
Because there's no context.reporter.sendTextAlert? I don't remember, so you're probably right as rain.
There was a problem hiding this comment.
I remember now, we're just appending to the reported error; we don't want to bump an error or warning count.
There was a problem hiding this comment.
The reportError function should take the optional text to append.
There was a problem hiding this comment.
Also, I don't know what 'start a review' and 'review changes' buttons do yet.
There was a problem hiding this comment.
I think this may be missed by tools, like Ensime/Eclipse and maybe even Sbt. It might play better if the additional text was part of the original error.
There was a problem hiding this comment.
I thought about it briefly last night and agree, but not sure about code yet. I haven't looked at dotty "explain" messages yet, and whether they include an "append advice" feature. I like the idea of decoupled, "something happened, and this additional text may help."
|
More retro history is that the crasher fix on 2.12 is #5179 |
db9290a to
1854742
Compare
|
Before issuing errors, update the error(s) at the tree.pos with the additional text. It would be nicer to |
|
@SethTisue "Hello, Seth, can you tell me how I broke the build?" (If I could talk to Seth's Build Tool like Siri.) |
|
scala/scala-dev#251 is looking less and less spurious. |
|
“Spuriouser and spuriouser!” Cried Alice (she was so much surprised, that for the moment she quite forgot how to speak good English). |
|
How about showing the expansion as well: I see the caret operator is not shown as |
If rewriting `x += y` fails to typecheck, emit error messages for both the original tree and the assignment. If rewrite is not attempted because `x` is a val, then say so. The error message at `tree.pos` is updated with the additional advice. SI-8763 Crash in update conversion When there are already errors, don't attempt mechanical rewrites.
1854742 to
76598e8
Compare
|
/rebuild |
|
Looks very nice. Could we even include the receiver expression? |
This can lead to poor messages in cases when the expression is long, or contained desugarings. Usually we just identify it with the error position and only refer to the expressions type in the message. |
|
That was my original reason, although the word I also forgot my comment that the expansion string shows The message will be perfect in dotty... |
If rewriting x += y fails to typecheck, emit error messages
for both the original tree and the assignment.
If rewrite is not attempted because x is a val, then say so.
Supersedes #5254 from last June. I must've forgotten it was against 2.11. What fashions did we wear and what music did we listen to back then? Who was president?