www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22981] New: Another forward reference bug involving a string

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

          Issue ID: 22981
           Summary: Another forward reference bug involving a string mixin
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: maxsamukha gmail.com

A reduced test case:

mixin ("enum E {", S.attr, "}");

struct S
{
    E e;
    enum attr = "a";
}

void main()
{
}

onlineapp.d(7): Error: undefined identifier `E`


The test case compiles if the enum is wrapped in a template:

template E()
{
    mixin ("enum E {", S.attr, "}");
}

struct S
{
    E!() e;
    enum attr = "a";
}

--
Apr 04 2022