[Issue 7386] Can't use a 'version' that was set inside 'static if'

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 9 22:56:49 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=7386

Dennis <dkorpel at live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel at live.nl

--- Comment #2 from Dennis <dkorpel at live.nl> ---
> The compiler's evaluation seems to occur in the wrong order ("versions before static ifs" instead of "top to bottom")

This 'evaluation order' is totally underspecified and super tricky. Simply
going top to bottom doesn't work since a static if can have forward references:

```
static if (x == 0) {
    version = X1;
}

version(X1) {

}

enum x = 0;
```

Even trickier:
```
static if (x == 0) {
    version = X1;
}

version(X1) {
    version = X2;
}

version(X2) {
    enum x = 0;
}
```

--


More information about the Digitalmars-d-bugs mailing list