[Issue 11697] New: Cannot initialize enum with class or pointer to struct.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 6 12:57:57 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11697

           Summary: Cannot initialize enum with class or pointer to
                    struct.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: samukha at voliacable.com


--- Comment #0 from Max Samukha <samukha at voliacable.com> 2013-12-06 12:57:55 PST ---
class A
{
    int x = 1;
}

enum a = new A;
static assert(a.x == 1);

Error: Unable to initialize enum with class or pointer to struct. Use static
const variable instead.


The limitation is annoying as it has to be sidestepped by wrapping the
reference in a struct. Compiles:

struct S
{
    A a;
}

enum s = S(new A);
static assert(s.a.x == 1);

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list