dotnet/csharpstandard

[Nullable Reference Types] Specify nullable flow analysis lattice

BillWagner opened this issue · 4 comments

Specify the general rules for static flow analysis of nullable states. Namely, the standard should specify:

  • The possible null-state of a variable or expression (not-null or maybe-null)
  • The initial nullable state of a variable, based on the nullable context and its declared type
  • Some general rules about flow analysis and diagnostics.

That final bullet is fraught with risk. We don't want to constrain any future compiler innovations that improve static analysis. However, we need to paint some general view of the diagnostics to provide useful information both for compiler writers and C# programmers.

See https://github.com/dotnet/csharpstandard/pull/1124/files#r1632781297 for more context here.

Depending on the resolution of that conversation, this PR should clarify how property accessors are handled. The result of invoking the set accessor, or the null-state of the value returned by a get accessor impacts the null-state of subsequent get accessors.

Stated non-normatively, the null state of a property is treated as though it is a variable.

That is not true for method invocations: Their result is not considered consistent between invocations.