-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersBugFeature - Nullable Reference TypesNullable Reference TypesNullable Reference TypesUrgency-Soon
Milestone
Description
class C<T>
{
bool Method([MaybeNullWhen(false)] out T value)
{
...
return someBoolLocal; // will warn and is hard to suppress
}
}Should we relax the enforcement (since we don't track bool locals), or should we offer a way of suppressing?
Relates to dotnet/runtime#36104 (comment)
Options so far:
-
assertions don’t work as far as I can tell
Even making the two explicit branches of the return explicit with anif (someBoolLocal) { someAssertion(); return true; } else { return false; }there are no good assertions that resolve this. -
suppression with
!
You could bang all the assignments tovalue. Seems smelly though -
explicit suppression
#pragma warning disable CS8762 -
allow silencing the return statement
return someBoolLocal !;. -
Only warn when we know the value of
someBoolLocal.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-CompilersBugFeature - Nullable Reference TypesNullable Reference TypesNullable Reference TypesUrgency-Soon
Type
Projects
Status
Active/Investigating