dotnet/roslyn
Auf GitHub ansehenGot a false CS8602 warnning when use Null-conditional operator and Null-coalescing opreator in expression
Open
#78.432 geöffnet am 3. Mai 2025
Area-CompilersBugFeature - Nullable Reference Typeshelp wanted
Repository-Metriken
- Stars
- (20.414 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)
Beschreibung
Version Used:
- csc.dll:
4.13.0-3.25155.17+398aa319196d4684c751a3d7c75c847e519a393c - .NET SDK:
9.0.203-dc7acfa194
Steps to Reproduce:
- Compile follow code
- Got a false
CS8602warnning
using System;
AnotherTestClass? anotherTestClass = null;
if (!anotherTestClass?.IsTrue ?? false)
{
// CS8602 at `anotherTestClass`
Console.WriteLine(anotherTestClass.IsTrue
? "Cancellation requested"
: "Cancellation not requested");
}
Console.WriteLine("Test method ended");
class AnotherTestClass
{
public bool IsTrue = false;
}
Diagnostic Id:
CS8602: Dereference of a possibly null reference.
Expected Behavior:
No warnning
Actual Behavior:
Got a falseCS8602 warnning