[Issue 21828] New: Using enum of struct (containing another enum) before its declaration fails

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 15 10:41:46 UTC 2021


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 at puremagic.com
          Reporter: dlang-bugzilla at 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.

--


More information about the Digitalmars-d-bugs mailing list