You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
warning FS3261: Nullness warning: The types 'string' and 'string | null' do not have compatible nullability.
Why
This error is not especially friendly or easy to understand, nor does it give a solution to fix the issue.
How
Consider replacing with:
warning FS3261: The symbol `x` may be null, and accessing the `Length` member could lead to a runtime exception. Consider pattern matching and / or converting to an Option using 'Option.ofObj' to safely access the value.
The text was updated successfully, but these errors were encountered:
warning FS3261: Nullness warning: The types 'string' and 'string | null' do not have compatible nullability.
->
warning FS3261: The symbol x may be null, and accessing the Length member could lead to a runtime exception. Consider pattern matching and / or converting to an Option using 'Option.ofObj' to safely access the value.
->
warning FS3261: Nullness warning: Accessing Length on x is not null-safe and can fail at runtime. More about null-safe member access: URL
url: a doc page explaining null checks, non-null, more details about use cases, performance implication, etc.
I don't feel we should recommend Option.ofObj or a specific way to make the code null-safe, but rather link to a dedicated and comprehensive page.
@smoothdeveloper That's a good point - I had a similar thought. However, I'm not aware of this being done anywhere else in error messages for F# (although we have started doing this in SAFE Stack packages). You're right that Option.ofObj is opinionated, but realistically, what other ways of safely handling nullness in F# is there - pattern match on null or convert to Option and then use pattern matching / map etc.?
What
The standard FS3261 warning for e.g.
is as follows:
Why
This error is not especially friendly or easy to understand, nor does it give a solution to fix the issue.
How
Consider replacing with:
The text was updated successfully, but these errors were encountered: