Why use a DFA instead of DIP1000?
kdevel
kdevel at vogtner.de
Sat Sep 13 19:58:53 UTC 2025
On Saturday, 13 September 2025 at 15:43:27 UTC, Richard (Rikki)
Andrew Cattermole wrote:
> [...]
>> I thought that the intent of the original code
>>
>> ```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`
>> }
>> }
>> ```
>>
>> was to show that there is some code-block
>>
>> ```d
>> ptr = p; // Error: scope variable `p` assigned to global
>> variable `ptr`
>> ```
>>
>> which is never executed regardless of the value of `b`.
>
> Half right.
>
> There is a code block that will never be executed, it is
> because of variable b's state is known to prevent that code
> block from execution.
Then it is dead code that should be manually removed? Isn't that
the problem here? The compiler correctly complains about invalid
code, this is not a false positive, even if that code is never
executed.
If I want code not to be executed I comment it out or delete it.
More information about the Digitalmars-d
mailing list