We all get nullability wrong sometimes
Asadbek
aosindarov at gmail.com
Thu Jul 9 19:35:30 UTC 2026
On Thursday, 9 July 2026 at 18:13:14 UTC, Richard (Rikki) Andrew
Cattermole wrote:
> On 10/07/2026 3:38 AM, Asadbek wrote:
>> On Thursday, 9 July 2026 at 14:33:54 UTC, Richard (Rikki)
>> Andrew Cattermole wrote:
>>> [...]
>>
>> 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 ?
>
> I want to clarify something first up, the correct term is
> Abstract Interpretation, Data Flow Analysis is an application
> of Abstract Interpretation for backend optimizations.
>
> The fast DFA engine isn't actually a DFA, since it has nothing
> to do with backends, but might do optimizations via setting
> flags in the future.
>
> Why did I call it DFA two years ago? That was because I didn't
> know that Abstract Interpretation was the correct term, the
> literature tends to confuse the two quite heavily and I don't
> think Walter knew of it either.
>
> There is no point renaming it today, it would just confusing
> what with LLM's all about.
>
> To answer your question, yes the fast DFA engine there is
> catching that catchIdent is null, and then erroring. Rather
> than letting it perform a null dereference at runtime.
>
> But please note that this is occurring in my PR for escape
> analysis that I am currently working on.
>
> Principles of Abstract Interpretation is the book I recommend
> for anyone interested in learning more of the subject. It is
> written by the original 1970's author who created the term.
> https://mitpress.mit.edu/9780262044905/principles-of-abstract-interpretation/
Thank you for the suggestion, will definitely check it out. I had
lectures about data flow and abstract interpretation as part of
program analysis in a compiler course. We only did middle-end
optimizations on the LLVM IR not on AST level of our own toy
compiler though. I believe dmd does not have its own dedicated
IR, do you do the analysis at the AST level ?
More information about the Digitalmars-d
mailing list