www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12665] New: Cannot create enum of struct within the struct,

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

          Issue ID: 12665
           Summary: Cannot create enum of struct within the struct, if the
                    struct has a constructor ("cannot create a struct
                    until its size is determined")
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: smjg iname.com
            Blocks: 340

DMD 2.065 Win32

----------
struct DateInterval {
    int value;
    this(int v) { value = v; }

    enum YEAR = DateInterval(365);
}
----------
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd datetime.d
datetime.d(5): Error: cannot create a struct until its size is determined
----------

Same error occurs if I use either

    enum {
        YEAR = DateInterval(365)
    }

or

    enum : DateInterval {
        YEAR = DateInterval(365)
    }

instead.  However,

    enum DateInterval YEAR = DateInterval(365);

compiles without error.

This has broken Stewart's Utility Library.

--
Apr 27 2014