Open johnnyggalt opened 4 days ago
I am confused about the source line of the error, like 20 is the " | Ok " match clause, isn't it?
@T-Gro that's correct. It seems to me that the combination of null checking and the specifics of my scenario is causing the compiler to get confused.
Some previous defaults of type inference, such as falling back to 'obj' in some cases, are no longer possible with nullness due to the difference between obj and objnull. This should be validate with trying similar code with and without explicit annotations for the usages of the Result.
Looking at the code, it should be able to derive type of Result to be <int,string> (non nullable string) .
@T-Gro if I explicitly type the result
, it does compile:
let result: Result<SomeRecordWrapper, string> =
...
Whilst this should get me past my issue, it feels off to me. At the very least, the compiler error message is hella confusing. But on top of that, if I don't explicitly type result
it still correctly inferred, so the explicit typing feels unnecessary from that perspective:
Issue description
A specific scenario is broken by enabling nullness checking, manifesting as
FS0001
.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
With
Nullable
enabled, this results in:With
Nullable
disabled, the code compiles fine.Possible workarounds
None that I know of.