-
Notifications
You must be signed in to change notification settings - Fork 74
Struct's default constructor does not get called implicitly #381
Comments
When I try to compile a minimal sample using VS2012 I get a compilation error. Which setup are you using? If you're not using Visual Studio it's mono's responsibility to report this error, and perhaps it does not support that. |
I am using Visual Studio 2015 Preview. Try this code:
As long as you initialize all fields of the returned struct within every possible code path in the function, it is OK not to explicitly call the constructor. |
Ah, thank you! |
Another case:
|
@TriEdgeAI That case is going to be very hard (impossible?) to fix. At least I have no idea of how to do it. |
I am not aware how the compiler works internally, but can't you generate an additional for-loop which initializes all elements to default(T), whenever new T[] is performed, such that T is value type? |
C# Code:
Generated JavaScript code:
Which results in an error, when running it. Instead it should be like so:
The text was updated successfully, but these errors were encountered: