-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nullness issue - compilation broken by FS0001 when enabling nullness checks #18034
Comments
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. 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 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 |
It does indeed. It has to do with the constraints implied by the use of "monad" CE - not that it has an issue in it, but rather the compiler solving constraints wrong for it in the presence of nullable changes. We definitely first need to check this with a smaller isolated computation expression (= a trimmed down version of "monad"), to minimize the suspects. |
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.
The text was updated successfully, but these errors were encountered: