www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21828] New: Using enum of struct (containing another enum)

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

          Issue ID: 21828
           Summary: Using enum of struct (containing another enum) before
                    its declaration fails
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

//////// test.d ////////
struct S
{
    enum E
    {
        e1 = 0,
    }
    E e;
    enum S s1 = S(E.e1);
}

SE se;

enum SE
{
    e1 = S.s1
}
////////////////////////

test.d(8,15): Error: cannot implicitly convert expression `S(E.e1)` of type `S`
to `int`

If the declaration of `SE` and the use `SE se;` are reordered, the problem goes
away.

--
Apr 15