-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Milestone
Description
I don't think our current inference design interacts with finally blocks well:
C? c = null;
try
{
c = SomeNonNullComputation;
}
finally
{
if (c != null) c.Cleanup();
}
c.Operation(); // undeserved warningWe infer from c != null that c might be null. That inference leaks out to the enclosing construct. The result is a warning when c is used after the try-finally statement. This will be a common pain point.
I don't think indirect inferences from inside a finally block should leak out to the enclosing context. An inference from an actual assignment in the finally block should indeed leak out, though.
Reactions are currently unavailable