[dmd-internals] Internal compiler error handling

Martin Nowak via dmd-internals dmd-internals at puremagic.com
Fri Oct 7 01:55:57 PDT 2016


On 09/27/2016 11:40 AM, Mathias Lang via dmd-internals wrote:
> One of the solution proposed by Martin was to provide a switch to allow
> `assert`. This has the disadvantage of still stripping `invariant` and
> `in`/`out` contracts, and might be confusing to user code.

We don't really use contracts/invariants in dmd. And honestly, except
for class hierarchies (where the implementation is fairly buggy though),
contracts/invariants don't provide much over asserts.
We also guessed that invariants are mainly responsible for the high cost
of disabling release.

The idea for the switch was -release=assert,invariant,contracts to
reenable particular checks.

> One other solution - which doesn't require a language change - would be
> to use exception for ICE (which are rare anyway), and provide a
> comprehensive handler at the top level to:

Assertions already are using EH (they are Errors), but not in release
builds.
Currently EH still is far from zero cost (not sure about nothrow Errors
in release).
For now I'd be in favor of a pragmatic iceAssert or so method that just
prints file+line and exits (in fact just reuse much like the old
assert). In fact, just reuse util_assert and be done.

> - Provide a nice error message

Nobody will write/maintain nice errors for ICEs, they should simply
never happen. Exact compiler version (dmd --version provided by
reporter), file, line number, and maybe some extra arguments is all that
is needed.

> - Provide a dump of the code / AST that produced the error

Fancy, but w/ Dustmite we already have a tool to reduce test cases.
Also ICEs are usually rather simple to fix.

> - Point to bugzilla, as suggested in a recent P.R. by Dicebot:
> https://github.com/dlang/dmd/pull/6103

Yes, that's a good idea.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20161007/e9a318a9/attachment.sig>


More information about the dmd-internals mailing list