Why use a DFA instead of DIP1000?

kdevel kdevel at vogtner.de
Sat Sep 13 10:19:45 UTC 2025


On Saturday, 13 September 2025 at 02:39:40 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> [...]
> Afterwards, I came up with an example, where DIP1000 will error:
>
> ```d
> int* ptr;
>
> void func(bool b, scope int* p) @safe {
>   assert(!b);
>
>   if (b) {
>     ptr = p; // Error: scope variable `p` assigned to global 
> variable `ptr`
>   }
> }
> ```
>
> This is clearly a false positive; that branch could never run!

What about "release" mode? And what about that code:

```d
void main ()
{
    assert (0);

    string s = "x";
    s [0] = 'y';
}
```

Is "Error: cannot modify `immutable` expression `s[0]`" a false 
positive, too?


More information about the Digitalmars-d mailing list