Quality of errors in DMD
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 3 05:12:34 PDT 2016
On 9/3/2016 3:57 AM, Ethan Watson wrote:
> Browsing through that function, I can also see another assert that doesn't let
> you use vector types unless you're running a 64-bit build or are on OSX. It
> doesn't tell me that through an error message. I had to look at the source code
> to work it out. fatal_error("Vector types unavailable on the target platform");
> and someone's day was made better. And then a couple of lines above that,
> another assert(0). fatal_error("Invalid vector type %s", tx->toChars()); and
> someone can deal with the unexpected.
This appears to conflate diagnosing errors in the user's source code with
detecting bugs in the compiler. A user source code error should have been
diagnosed long before those asserts are hit (and if not, it's a compiler bug, by
definition, not a user source code problem).
> If I have to open up the compiler's source to get an idea of what I'm doing
> wrong, that's a bad user experience. And why I want a discussion about this. Not
> to whinge, not to get a bug fix. But to highlight that assert(0) is a bad
> pattern and there should be a discussion about changing the usage of asserts
> inside DMD.
Except that asserts are checking for compiler bugs, not diagnostics on user
code. I don't expect users to debug the compiler - if they get an assert they
should file a bug report to bugzilla and let us debug the compiler and fix it.
----
Aside: we regularly have threads here where the difference between detecting
programming bugs and detecting input errors is discussed. I fear another one is
gathering steam, and if so, I'll likely not participate in it.
More information about the Digitalmars-d
mailing list