Open 13xforever opened 3 years ago
Think this repro can be simplified to the following
using System;
using System.Threading.Tasks;
#nullable enable
public class C {
static (C?, bool) M(C p) => throw null!;
void Repro() {
C? local = new C();
// Warns
(local, _) = M(local);
// Does not warn
local = new C();
(_, _) = M(local);
}
}
The core problem here is that we appear to be using the result of the deconstruction to update the state of the local before it is used in the call expression where it should be updated after.
If you're interested in non-contrived code samples, (state, _) = Reduce(state, ...)
happens frequently in test code for one project.
Version Used: Dotnet SDK 5.0.0
Steps to Reproduce: Not sure if relates to #35349, but here's a repro:
Expected Behavior: No warning given
Actual Behavior: I'd expect the result of
NonNullableResult()
to be not null, at least by the timeMaybeNullableResult()
is called on it. if you change code to bewarning goes away, which is kinda confirms it?