-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Milestone
Description
Splitting issue out of #26745
Null-coalescing operators should affect the flow analysis of null values.
Here's an example reported by @bgrainger: https://github.com/bgrainger/NullableReferenceTypes/blob/master/NullCoalescingProperty.cs
namespace NullableReferenceTypes
{
class NullCoalescingProperty
{
public void ClearChild(Node? parent)
{
if (parent?.Left != null)
{
// warning CS8602: Possible dereference of a null reference.
// however, we know that parent.Left != null, therefore parent != null
parent.Left = null;
}
}
}
class Node
{
public Node? Left { get; set; }
public Node? Right { get; set; }
}
}Once fixed, please update this speclet section.
Reactions are currently unavailable