Thread overview
[Issue 20905] Type definition inside a static if results in an undefined identifier
[Issue 20905] An alias inside a static if results in an undefined identifier in some situations
Jun 14, 2020
KytoDragon
Jun 14, 2020
KytoDragon
Oct 03, 2020
KytoDragon
Oct 03, 2020
KytoDragon
Nov 08, 2020
foerdi
Apr 11, 2022
Iain Buclaw
Jun 02, 2022
kinke
Dec 17, 2022
Iain Buclaw
June 14, 2020
https://issues.dlang.org/show_bug.cgi?id=20905

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

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

--
June 14, 2020
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, 2020
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, 2020
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, 2020
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;
}
```

--
April 11, 2022
https://issues.dlang.org/show_bug.cgi?id=20905

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=21171,
                   |                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=17883

--
June 02, 2022
https://issues.dlang.org/show_bug.cgi?id=20905

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=16666

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=20905

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--