We all get nullability wrong sometimes
Asadbek
aosindarov at gmail.com
Thu Jul 9 15:38:08 UTC 2026
On Thursday, 9 July 2026 at 14:33:54 UTC, Richard (Rikki) Andrew
Cattermole wrote:
> Here is a nice little showcase of what the fast DFA engine is
> able to do:
>
> ``class IdentExpr``
>
> https://github.com/higgsjs/Higgs/blob/master/source/parser/ast.d#L986
>
> ```d
> catchIdent = cast(IdentExpr)parseExpr(input);
> if (catchIdent is null)
> throw new ParseError("invalid catch
> identifier", catchIdent.pos);
> ```
>
> https://github.com/higgsjs/Higgs/blob/master/source/parser/parser.d#L462
>
> Anyone notice a slight problem with this code?
>
> While a sound static analyser would be nice, being able to
> catch code like this does mean bugs don't sit around for 10+
> years in production code, just waiting to give someone a very
> bad day.
>
> https://github.com/higgsjs/Higgs/issues/219
I have just checked dmd repository and it appears dmd compiler
has custom data flow analysis optimizations. That is really great!
Is DFA analysis proving that the `catchIdent` is `null` and
therefore catching what would be a runtime error at compile time ?
More information about the Digitalmars-d
mailing list