[dmd-internals] Internal compiler error handling

Mathias Lang via dmd-internals dmd-internals at puremagic.com
Tue Sep 27 02:40:32 PDT 2016


Hello DMD devs,

Since we switched to DDMD, there has been a major regression hanging 
around: asserts are stripped out of the version we ship (except for 
assert(0)), because for performance reason we ship with `-release`.
This can lead to very subtle and hard to spot bug in user code, and 
requiring someone to build a debug version of DMD in order to post a bug 
report is a clear red flag.

There has been discussions on what to do with this, in this P.R. : 
https://github.com/dlang/dmd/pull/5716

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.

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:
- Provide a nice error message
- Provide a dump of the code / AST that produced the error
- Point to bugzilla, as suggested in a recent P.R. by Dicebot: 
https://github.com/dlang/dmd/pull/6103

Thoughts ?



More information about the dmd-internals mailing list