Open glchapman opened 6 days ago
I just reread the section "Inference in generic code" from Nullable Reference Types in F# 9. I thought perhaps it meant that the following should work without a warning, but a warning is still generated
let useThing<'d when 'd: not struct and 'd :> IDisposable> (thing: 'd) =
try
printfn "%O" thing
finally
dispose thing // warning generated
Could you please also include which warning this produces incl. the range (= coordinates in code) for it?
The warning is:
Program.fs(12,17): warning FS3261: Nullness warning: The types 'IDisposable' and 'IDisposable | null' do not have equivalent nullability.
In VSCode, thing
in the last line (dispose thing
) is highlighted.
Issue description
I get a nullness warning with the following:
Since the dispose function allows null, I do not think a warning should be generated. No warning is generated for a non-flexible type, e.g.:
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
net9.0
Reproducible code snippet and actual behavior
No response
Possible workarounds
No response