[Issue 20905] New: An alias inside a static if results in an undefined identifier in some situations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 7 18:01:11 UTC 2020


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

          Issue ID: 20905
           Summary: An alias inside a static if results in an undefined
                    identifier in some situations
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: kytodragon at e.mail.de

This code:

struct Bar {
    Foo foo;  
}

static if (true) {
    alias my_type = ushort;
}

struct Foo {
    my_type index;  
}

results in this error:

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

Removing Bar or moving Bar after the static if fixes it. This also happens, if
Bar is defined in another file and imported into the one with the static if.

Reproduced on Windows x64 with DMD 2.092.0 and LDC 1.21.0.

--


More information about the Digitalmars-d-bugs mailing list