dotnet/roslyn
Lifted relational operators returning true should inform nullability tracking that neither operand can be null
Offen
#56.517 geöffnet am 18.09.2021
Area-CompilersBugFeature - Nullable Reference Typeshelp wanted
Repository-Metriken
- Stars
- (20.414 Sterne)
- PR-Merge-Metriken
- (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)
Beschreibung
Version Used: 17.0.0-p4.0
These two CS8629 diagnostics should not be generated:
#nullable enable
using System;
class C
{
void M(DateTime? a, DateTime? b)
{
if (a < b) // If this is true, neither variable can be null
{
// ⚠ CS8629 Nullable value type may be null.
// ↓
_ = a.Value;
// ↓
_ = b.Value;
}
}
}
For the relational operators
< > <= >=, [...t]he lifted operator produces the valuefalseif one or both operands are null.