Null state in unreachable code #32047
Labels
Area-Compilers
Area-Language Design
Need Design Review
The end user experience design needs to be reviewed and approved.
New Language Feature - Nullable Reference Types
Nullable Reference Types
Milestone
I think the null state of an expression should take into account when it occurs in unreachable code. An expression in unreachable code is never ever
null
. Even the expressionnull
is never null in unreachable code.This is not the same as simply suppressing warnings in unreachable code (though we should consider that too). For example:
Formally, my proposal is that an expression is never
null
in an unreachable statement, nevernull
when false after the constant true, nevernull
when true after the constant false, and nevernull
when false afterexpr is var x
and similar patterns (which are always true but not a constant). These all have in common that the “current” state in the nullable analysis should be the unreachable state when evaluating the code in question. That means there is a nice bottleneck in the rvalue-visiting method where this can be implemented.The text was updated successfully, but these errors were encountered: