version(number) is completely useless

Andrey Zherikov andrey.zherikov at gmail.com
Wed Jul 20 18:37:25 UTC 2022


On Wednesday, 20 July 2022 at 18:33:50 UTC, Andrey Zherikov wrote:
> On Wednesday, 20 July 2022 at 17:55:20 UTC, apz28 wrote:
>> Anyway, "static if" construct is not same as version
>> https://issues.dlang.org/show_bug.cgi?id=16666
>
> I don't thins that this is good example. The bug is actually 
> about that `static if` doesn't work with forward declaration:
> ```d
> void func(S s) {}
>
> version (WORKING)
>     struct S {}
> else static if (true)
>     struct S {}
> ```
> This fails with `Error: undefined identifier 'S'` and passes 
> with `dmd -version=WORKING`.
>
> Anyway this can be fixed.

The interesting thing is that only top-level `static if` fails. 
This works:
```d
void func(A.S s) {}

struct A
{
   version (WORKING)
     struct S {}
   else static if (true)
     struct S {}
}
```


More information about the Digitalmars-d mailing list