D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11697 - Cannot initialize enum with class or pointer to struct.
Summary: Cannot initialize enum with class or pointer to struct.
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-06 12:57 UTC by Max Samukha
Modified: 2024-12-13 18:14 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2013-12-06 12:57:55 UTC
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);
Comment 1 dlangBugzillaToGithub 2024-12-13 18:14:56 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18733

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB