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
The following code snippet leads to the resulting error message: -
letx=5if!x then"foo"else"bar"
This expression was expected to have type bool ref but here has type int
Why
The error is likely to occur for newcomers to the language who expect it to provide negation behaviour, when F# sees it as ref cell deferefencing, hence the confusing error message. With the improved support for implicit handling of rec cells through the mutable keyword, this error could be reworded to explain that perhaps they meant not instead of !.
How
Suggest an error wording as follows: -
The ! operator is used to dereference a ref cell. Did you want to negate the expression instead? If so, consider using 'not expression' instead.
The text was updated successfully, but these errors were encountered:
What
The following code snippet leads to the resulting error message: -
This expression was expected to have type bool ref but here has type int
Why
The error is likely to occur for newcomers to the language who expect it to provide negation behaviour, when F# sees it as ref cell deferefencing, hence the confusing error message. With the improved support for implicit handling of rec cells through the mutable keyword, this error could be reworded to explain that perhaps they meant
not
instead of!
.How
Suggest an error wording as follows: -
The ! operator is used to dereference a ref cell. Did you want to negate the expression instead? If so, consider using 'not expression' instead
.The text was updated successfully, but these errors were encountered: