Emit a warning when x.ToString(), x.GetHashCode or x.Equals(y) are used directly on option-typed values
Open
Area-Diagnostics
Feature Improvement
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
[@dsyme says] Proposal after discussion: emit a warning when x.ToString(), x.GetHashCode or x.Equals(y) are used directly on option-typed values, suggesting to use string or x = y instead. Or more generally when Equals, GetHashCode or ToString are used on F#-declared types known to have null as a representation.
### Description
None.ToString();;
None.GetHashCode();;
None.Equals(None);;
lead to NullReferenceException in fsi and fsc.
#### Known workarounds
Use ``string x``, ``hash x`` and ``x = y``
Contributor guide
Assessment
This issue has not been assessed yet.