Nullness issue - type inference on pattern match for nullable values is unexpected #18012
Open
2 of 7 tasks
Labels
Milestone
Issue description
The following code triggers FS3261:
with
blip
being inferred as typestring
. The above should reasonably be inferred asstring | null
, and I believe the equivalent of the above usingif
/then
/else
does indeed do that.Choose one or more from the following categories of impact
null
constructs in code not using the checknulls switch.null
,not null
).Operating System
Windows (Default)
What .NET runtime/SDK kind are you seeing the issue on
.NET SDK (.NET Core, .NET 5+)
.NET Runtime/SDK version
.NET 9
Reproducible code snippet and actual behavior
Possible workarounds
Add a type annotation on
blip
e.g.blip : string | null
.The text was updated successfully, but these errors were encountered: