Skip to content

Why doesn't C# realise that this reference type variable is guaranteed to be set? #7675

Closed Answered by HaloFour
jez9999 asked this question in General
Discussion options

You must be logged in to vote

Because nullable flow analysis does not track boolean conditions across variable assignments. I believe that there is a proposal to expand that to support trivial cases like this one, but there will always be a limit to how far flow analysis will be willing to interpret and evaluate the code to determine which code paths may or may not execute.

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@HaloFour
Comment options

@CyrusNajmabadi
Comment options

@tannergooding
Comment options

@jez9999
Comment options

@jez9999
Comment options

Answer selected by CyrusNajmabadi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants