A Philosophy of Software Design
Basile B.
b2.temp at gmx.com
Sun May 24 12:55:42 UTC 2026
On Sunday, 24 May 2026 at 06:49:28 UTC, Richard (Rikki) Andrew
Cattermole wrote:
> On 24/05/2026 4:10 PM, Walter Bright wrote:
>> Invalid code nodes are replaced with "Error" nodes. This
>> worked far better than I anticipated. No exceptions are
>> thrown. It also behaves like NaN.
>
> That's not actually how you handled it, although I'm sure it
> solved some problems much more easily.
>
> You handled it by checking the error count. In other words a
> global flag.
>
> https://github.com/dlang/dmd/blob/3c2ad72ad3be9c38c76569ccd1574e39fec2256d/compiler/src/dmd/typesem.d#L4787
>
> https://github.com/dlang/dmd/blob/3c2ad72ad3be9c38c76569ccd1574e39fec2256d/compiler/src/dmd/globals.d#L368
>
> If you can get an error node without an error message that is
> an ICE that should have been emitted but wasn't.
I think a better example is when in expsema the type of an
expression is set to Terror.
1. This avoids plenty of null checks
2. This poisons the AST, so that, for example, further
conversions wont pass
What you put links on is rather the system used for error
recovery. Generally I find that error gagging is clumsy but that
is casually required (`__traits(compiles)`, `typeof()`, selection
in an overload set, SFINAE, etc.)
But finally I dont really see how exceptions are related to
compiler errors. I've never seen a compiler using them for
notifying invalid input code. Invalid input code is unrelated to
compiler "as a software" errors (e.g a input file that does not
exist).
More information about the Digitalmars-d
mailing list