D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12665 - Cannot create enum of struct within the struct, if the struct has a constructor ("cannot create a struct until its size is determined")
Summary: Cannot create enum of struct within the struct, if the struct has a construct...
Status: RESOLVED DUPLICATE of issue 9397
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P1 regression
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2014-04-27 16:29 UTC by Stewart Gordon
Modified: 2014-05-02 12:14 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Stewart Gordon 2014-04-27 16:29:35 UTC
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.
Comment 1 Andrej Mitrovic 2014-04-27 18:34:55 UTC
This has been like this since 2.062. I've seen another bug report like this somewhere.
Comment 2 Vladimir Panteleev 2014-05-01 19:45:42 UTC
Introduced in https://github.com/D-Programming-Language/dmd/pull/1157
Comment 3 Andrej Mitrovic 2014-05-01 19:47:57 UTC
(In reply to Vladimir Panteleev from comment #2)
> Introduced in https://github.com/D-Programming-Language/dmd/pull/1157

Ha, I knew it was something old. But I also remember something about this being deliberate.
Comment 4 Vladimir Panteleev 2014-05-01 19:49:37 UTC
Oh, didn't look closely at the patch and error message. So is it deliberate?
Comment 5 Andrej Mitrovic 2014-05-01 19:53:36 UTC
(In reply to Vladimir Panteleev from comment #4)
> Oh, didn't look closely at the patch and error message. So is it deliberate?

Actually I recall it being a bugzilla comment, not the pull request itself. I'm not sure anymore, but I'll CC Don.
Comment 6 Andrej Mitrovic 2014-05-01 19:57:23 UTC
Found it:

https://issues.dlang.org/show_bug.cgi?id=9397#c3
Comment 7 Andrej Mitrovic 2014-05-01 19:58:04 UTC

*** This issue has been marked as a duplicate of issue 9397 ***