Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot initialize enum with class or pointer to struct. #18733

Open
dlangBugzillaToGithub opened this issue Dec 6, 2013 · 0 comments
Open

Cannot initialize enum with class or pointer to struct. #18733

dlangBugzillaToGithub opened this issue Dec 6, 2013 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

Max Samukha reported this on 2013-12-06T12:57:55Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=11697

Description

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant