Thread overview
[Issue 20905] An alias inside a static if results in an undefined identifier in some situations
[Issue 20905] Type definition inside a static if results in an undefined identifier
Nov 08
foerdi
June 14
https://issues.dlang.org/show_bug.cgi?id=20905

KytoDragon <kytodragon@e.mail.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major

--
June 14
https://issues.dlang.org/show_bug.cgi?id=20905

--- Comment #1 from KytoDragon <kytodragon@e.mail.de> ---
I changed the importance to major since if you import the file that contains the static if this can't even be fixed by reordering symbols/imports.

--
October 03
https://issues.dlang.org/show_bug.cgi?id=20905

--- Comment #2 from KytoDragon <kytodragon@e.mail.de> ---
It turns out you don't even need an alias for it to fail:

struct Bar {
    Foo foo;
}

static if (true) {
    struct my_type {
        int a;
    }
}

struct Foo {
    my_type index;
}

test.d(12): Error: undefined identifier `my_type`

--
October 03
https://issues.dlang.org/show_bug.cgi?id=20905

KytoDragon <kytodragon@e.mail.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|An alias inside a static if |Type definition inside a
                   |results in an undefined     |static if results in an
                   |identifier in some          |undefined identifier
                   |situations                  |

--
November 08
https://issues.dlang.org/show_bug.cgi?id=20905

foerdi <dlang@foerdi.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dlang@foerdi.net

--- Comment #3 from foerdi <dlang@foerdi.net> ---
It seems that this depends on the definition order.

A reduced example:
```
struct Foo {
    my_type index;
}

static if(true) {
    alias my_type = int;
}
```
Error: undefined identifier my_type

This example works:
```
static if(true) {
    alias my_type = int;
}

struct Foo {
    my_type index;
}
```

--