-
Notifications
You must be signed in to change notification settings - Fork 4.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
Track conditionally assigned variables by condition #31893
Comments
We don't track the values of variables, and that is unlikely to be added to the scope of this NRT feature. |
I was raising an issue but found it to be duplicate of this issue while writing it: "It should not be an error (or null warning) to use a conditionally assigned variable under the same condition it was assigned" I'm unsure if the variant of this relating to use of unassigned variables is the same or different, so i'll post here to avoid cluttering issues. Version Used:
Expected Behavior: Actual Behavior: As a side note, i started from an unexpected "this could be null" warning with nullability enabled, which was similar to #31893, but i only found that ticket after simplifying down to the 'unassigned use' example found here #31893, has the comment of "we don't trace values" however: The following code does compile, so the compiler is capable of understanding that both the true and false branches of the code produce sensible outcomes :
|
this doesn't have to do value tracking; it only needs to determine that access and assignment are guarded by the same condition. |
This is a language feature request, so belongs in |
Version Used:
3.0.0-beta2-18616-01
Steps to Reproduce:
Expected Behavior:
No warning
Actual Behavior:
UnitTest1.cs(8,22,8,23): warning CS8604: Possible null reference argument for parameter 'o' in 'object C.F(object o)'.
The text was updated successfully, but these errors were encountered: