Open kerams opened 1 month ago
Thanks, yeah, that should infer non-nullable. We are likely not make it the fix before sdk freeze (next Monday), but following release.
Yes, that does make more sense. I believe that in this case, the inference for the "work" agnostic function took precedence. The call will still work and will be open to a bigger variety of inputs for "whatever", however quickly becomes a negative once there are more lines working with "x" further below.
In the general case (ignoring ofObj), the inference should favour values without null, but fslib functions were special cased in a few places.
@kerams the title says ofObj
, but you meant toObj
, correct?
Issue description
When trying to pass a
string option
value to a null-agnostic method takingstring
usingOption.toObj
, the input type gets inferred asstring | null option
.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
9.0.100-rc.1.24452.12
Reproducible code snippet and actual behavior
The type of
whatever
is inferred to bestring | null option -> unit
, butstring option -> unit
seems more reasonable.Possible workarounds