Open jozkee opened 4 years ago
I'm not sure I would rank this high in priority, but I agree we could handle that.
I think it's a matter of keeping the value on the right in a split state when analyzing x = someSplitBoolValue
.
Copied the repro below:
#nullable enable
using System;
public class C {
public void M() {
Foo f = new Foo();
bool isNull;
if (isNull = f.Property != null)
{
Console.WriteLine(f.Property.ToLower()); // warning CS8602: Dereference of a possibly null reference.
}
}
}
public class Foo
{
public string? Property { get; set; }
}
Version Used: master (19 May 2020)
Steps to Reproduce:
Repro code: https://sharplab.io/#v2:EYLgtghgzgLgpgJwDQBMQGoA+BiAdgVwBtCJhC4ACOXU8gWACgABAJgEZGmBmC1igYQoBvRhTG8eTACwUAsgAoAlMNHi1qtWIBiAex0UAZhQC8FXHADuFXTqUBuDZsdrgewhQCWUAHJFCDhk1xDyN5L19iE0MAOgAFBB0AB0QYAE8KAEJTAmJFZ3ERQKDNJjYATnkDOITkhDTogBUdABkdC0QlRQDiigBfR36GQc5JFms9RkK1bl42AAYAfgp4pJT0oQoAczgYOwooHb3B3qA===
Expected Behavior: Object was already checked for null, nullability should no longer warn "Possible null reference".
Actual Behavior: Nullability still warn "Possible null reference" regardless of the previous null check.
cc @jaredpar @cston @jcouv