-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Warn on uninitialized fields for struct constructor with : this() clause
#48647
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
Conversation
|
New warnings in dotnet/runtime:
|
| #nullable disable warnings | ||
| public ConflictResolution(string errorMessage) : this() | ||
| => ErrorMessage = errorMessage; | ||
| #nullable enable warnings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CyrusNajmabadi for a spot check on this change. This PR fixes a bug that caused us to miss nullable field initialization warnings on a struct with a : this() initializer.
jcouv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler change LGTM Thanks (iteration 3)
|
running a VS validation insertion before merging here. update: we built VS successfully so will merge as soon as we get sign-off for IDE changes. https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/281961 |
Closes #48574
Basically, entering the
thisparameter caused the declared state to be written to the slots for the struct fields, so we need tomakeNotNullMembersMaybeNull()after theEnterParameter, not before. I think it also makes more sense to move the call into the!_isSpeculativeblock, since in speculative analysis we should just load a snapshot that already has the "state before we call base.Scan()" plugged into it. (if I'm reading the code right @333fred.)I think we should revisit the way we populate state when assigning to variables of struct types eventually (to solve #47596, for example).
@dotnet/roslyn-compiler for review please