Compiler warning for parameterless constructors? #5291
-
Is there plan to add warning to initialize structs without using the parameterless constructor? For example, I think it would be useful to have: struct A
{
public int a = 1;
}
A a1 = default; //warning
A a2 = default!; //OK
class B
{
private A a1; //warning
private A a2 = new(); //OK
} I am not sure whether assigning |
Beta Was this translation helpful? Give feedback.
Answered by
huoyaoyuan
Oct 17, 2021
Replies: 1 comment 3 replies
-
Your example looks more related to non-defaultable structs. I think the scenario should be covered then. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
acaly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your example looks more related to non-defaultable structs. I think the scenario should be covered then.