Why static analysis is the way to go

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Sat May 30 03:02:37 UTC 2026


On 30/05/2026 6:05 AM, Walter Bright wrote:
> On 5/28/2026 1:36 PM, Richard (Rikki) Andrew Cattermole wrote:
>> Also please note that nothrow @nogc and pure all rely on inference to 
>> work correctly, and dmd is unable to do this. As a result I would 
>> suggest to think of them as being on the chopping block at a future 
>> point in time.
> 
> Doing inference 100% requires dealing with recursive data flow. The 
> front end doesn't do that. However, in cases where recursion happens, 
> the compiler takes a conservative approach and assumes that the 
> attribute doesn't apply. This ensures the code is not broken.
> 
> The easy workaround is to simply explicitly put the attribute on the 
> recursive function.
> 
> This is not a disastrous defect.
Except that isn't the full story.

Dmd is inherently first come first served. Ordering matters.

Swap the order of two declarations and errors can appear and disappear 
as information is acquired.

We've mostly tuned the language to not exhibit these problems by simply 
being eager, and then you get cyclic and other awful errors.

There are somethings that we can't do in our type system, anything that 
requires inference for say effects is the big ticket item that is out. 
It may be unfortunate, but it does allow us to be fast at least, so not 
all bad.

Realistically the best thing we can do is say if you want effects 
modelling, its gonna cost and be opt-in. Those who don't care, will get 
the speed, and those that do care will happily pay.

A much better approach than making people suffer from attribute soup and 
PhobosV3 going: BAN ALL ATTRIBUTES! lol



More information about the Digitalmars-d mailing list