dotnet / dotnet/roslyn

Inconsistent nullable warning behavior involving the null-forgiving operator on the left-hand-side

Open
#75,997 0 comments 0 reactions 1 assignee Claimed by @jcouv View on GitHub
Area-Compilers Feature - Nullable Reference Types Feature - Tuples
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

There is inconsistent design around nullable diagnostics, illustrated below.

```csharp
class C
{
void M(
ref object o,
ref object p)
{
// error CS8598
(o!) = null;

// warning CS8600, despite ! operator
(o!, p!) = (1, null);

// no warning
(o!, p!) = this;

// no warning
// Deconstruct(out o!, out p!);
}

void Deconstruct(
out object? o,
out object? p)
{
o = null;
p = null;
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.