-
Notifications
You must be signed in to change notification settings - Fork 252
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
[BUG] Initializing an enum array does not compile #1316
Comments
I'm wondering if something really breaking has happened lately. I can't even get the hello world example to compile either. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@JohelEGP Yes, but what's the solution to my issue? It doesn't seem to be related to my problem. |
If you add
If you attempt to add an implicit default constructor, e.g. (https://cpp2.godbolt.org/z/hqonP3dbG):
It'll fail with:
If you want to use |
Yes, cpp2 enum should have a default constructor. |
Oh, but it does have a default constructor, it's just explicit. |
Ah yes indeed, thank you 😊 |
@JohelEGP In fact, I have the same problem with any objects, if I redefine the constructor. Color: type = {
value: i32 = 0;
operator=:(out this) = {
value++;
}
}
main: () = {
colors: std::array<Color, 1000> = ();
std::cout << Color[999].value << std::endl;
} This But my conclusion is that for the moment it's impossible to declare an array of 1000 objects without writing them all one by one. So to keep on progressing on my project I'll have to use Please feel free to correct me if I'm talking nonsense 😅 |
That |
Oh yes, sorry, I didn't realize that |
I try to compile this simple code:
The C++ code is generated correctly but I get an error when compiling.
Here is the code I ran:
https://cpp2.godbolt.org/z/MnrPqT4fK
The text was updated successfully, but these errors were encountered: