-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Improve definite assignment to understand coalescing with false and nullable comparison with true #3365
Comments
Seems that Roslyn always forgot to analyze patterns like Maybe you should open this issue in https://github.com/dotnet/roslyn/issues |
@hez2010 My understanding is that the C# definite assignment spec needs to be updated before Roslyn can do anything about the examples I gave in this issue, unlike the nullability warnings you mention. |
That's correct @jnm2. While I'm interested in championing this, I'd like to sit down with the definite assignment spec and see the level of change we'd need to make to support it, so before I actually tag it and such I'll work on that. |
My first example is a duplicate of #916. Is my second example close enough to close this as a dupe? (Hate to lose the 13 upvotes though..) |
Yeah, it's pretty much exactly the same as those. I will say that while I still want to come up with a spec for how this would work, I have not had the time (as you might be able to tell). If a community member wanted to make a proposal for how to modify the definite assignment rules, that's probably what would drive progress here. |
Okay, closing this in favor of the original at #916. Please upvote and follow there. |
These are forms of the same logic from most preferred to least preferred. The compiler does not consider them to be the same for the purpose of definite assignment, but it should.
The
?? false
and== true
guarantee that execution cannot move inside theif
block without first calling TryGetValue and assigning theout
parameter:Similar but for pattern matching rather than out parameters, and not involving nullability: #801
The text was updated successfully, but these errors were encountered: