Quality of errors in DMD
Ethan Watson via Digitalmars-d
digitalmars-d at puremagic.com
Fri Sep 2 07:26:37 PDT 2016
Can we have a serious discussion in here about the quality of DMD
errors?
I've been alternately a dog chasing its own tail, and a dog
barking at a fire hydrant, chasing down errors deep in templated
and mixin code over the last day. This has resulted in manually
reducing templates and mixins by hand until I get to the root of
the problem, which then results in submitting a bug and devising
an ugly workaround.
And then I get this one in some code:
Assertion failure: '0' on line 1492 in file 'glue.c'
The problem ended up being that a symbol tucked away in a
template that itself was tucked away in a template was undefined,
but it couldn't tell me that. Rather, it just assert(0)'d and
terminated. Rather less helpfully, the only meaningful
information it could give me at the assert point (Could it add to
it further down the stack? Maybe?) was defined out because DMD
wasn't in a debug build.
Honestly, I find stuff like this in a compiler unacceptable.
Using assert(0) as shorthand for an unexpected error is all fine
and dandy until you put your product in the hands of the masses
and they expect your program to at least give you some idea of
what was going wrong rather than just crashing out in flames.
So just for fun, I searched DMD for all instances of assert(0) in
the code base.
830 matches in DMD 2.070.2.
That's 830 possible places where the compiler will give the user
virtually no help to track down what (if anything) they did wrong.
DMD certainly isn't the only compiler guilty of this. The .NET
compiler gives precisely no useful information if it encounters
SSE types in C++ headers for example. But compared to MSVC, I've
found the error reporting of DMD to be severely lacking. In most
cases with MSVC, I have an error code that I can google for which
is (sometimes) thoroughly documented. And thanks to being a
widely used product, Stack Overflow usually gives me results that
I can use in my sleuthing.
I know I'm also seeing more errors than most because I'm doing
the kind of code most people don't do. But I'm certainly of the
opinion that searching for a compiler error code is far easier
than trying to trick google in to matching the text of my error
message.
More information about the Digitalmars-d
mailing list