-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Generate expressive diagnostic messages with the offending line #8487
Conversation
Thanks for your pull request, @wilzbach! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#8487" |
I like it. Would be nice to have as default. I’ve been thinking about fixits that Clang has as well. This would be especially useful for deprecations that usually contains a suggestion how to fix it. |
Added. For simplicity, I don't do the pretty printing for mixins for now though.
Yeah that's my goal too! |
I want to thank @wilzbach for finding a way to do this that doesn't involve changing 30 or 40 files :-) I like that the implementation is pretty encapsulated. When other PRs cross-cut through the files, it shows how poorly encapsulated the compiler internals are.
[On a personal note, I am annoyed by this, for the simple reason that the DMC C compiler has done the line with the caret since 1982, and not a soul ever cared for the feature or even mentioned it. So I dropped it for DMD. Suddenly, it's the height of fashion, innovation and modernity to have it, and I'm 180 degrees out of phase. Sigh.] |
In case I wasn't clear, yes, let's move forward with it. |
3c7d9ca
to
835a240
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a simple line-by-line cache, but before I figure out how to add it to all the makefile, it would be good to know if this should live in a separate module or somewhere else.
src/dmd/filecache.d
Outdated
|
||
static fileCache = FileCache(); | ||
|
||
shared static this() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should avoid module constructors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the module constructor, but now we need to manually initialize in mars.d
/ frontend.d
Moving forward post this pr, it would be really nice to have location ranges (start and end locations for all expressions). |
368c908
to
5be6c0d
Compare
Rebased this PR. It's still behind the |
src/dmd/errors.d
Outdated
// ignore invalid files | ||
loc != Loc.initial && | ||
// ignore mixins for now | ||
!loc.filename.strstr(".d-mixin-")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the addition of -mixin=<filename>
might want to doublecheck that logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. For now, I just added && !global.params.mixinOut
as that's definitely safe.
In the future, we probably need to call flushMixins
or make the fileCache aware of mixin files.
Ping @thewilsonator. Anything blocking this PR? |
A very naive implementation to ask on feedback on this before I invest more time in this.
Questions
Should we save the originally opened file (it's currently thrown away by default)? Re-opening them has the advantage of only paying this overhead in an error case.
Under which CLI flag should this be exposed?
Is there a chance that we can do sth. similar like we do with the coloring? Only if dmd is run in a terminal, turn of the expressive diagnostics by default if dmd, but still have flags to control the behavior manually
Clang calls this "expressive diagnostics" and there's a lot more cool stuff that we can do.
Motivation
Compiler error for humans sums it up pretty nicely.
Also note that all three major C++ compilers (Clang, GCC, MSVC) have such expressive diagnostics enabled by default. It's time for DMD to catch up with the modern era.