(=) and (<>) operators handle left operand being null incorrectly - throwing a NullReferenceException.
This is particularly unexpected, and makes these operators non-reflexive.
Repro steps
type Foo = Foo
let nullFoo = Unchecked.defaultof<Foo>
Foo = nullFoo // false - as expected
nullFoo = Foo // throws a NullReferenceException
Foo <> nullFoo // true - as expected
nullFoo <> Foo // throws a NullReferenceException
Expected behavior
(=) and (<>) operators should be reflexive.
Actual behavior
When the left operand of / first argument to the operator is null, a NullReferenceException is thrown.
Known workarounds
System.Object.Equals has the expected behaviour as described above.
Related information
Provide any related information
- Windows 7
- .NET 4.6.1
- F# 4.0
- Severity : within F# this is a relatively minor issue as you are unlikely to encounter null instances, however in interop scenarios this is fairly painful and, I would argue, extremely unexpected behaviour.
(=) and (<>) operators handle left operand being null incorrectly - throwing a NullReferenceException.
This is particularly unexpected, and makes these operators non-reflexive.
Repro steps
Expected behavior
(=) and (<>) operators should be reflexive.
Actual behavior
When the left operand of / first argument to the operator is null, a NullReferenceException is thrown.
Known workarounds
System.Object.Equals has the expected behaviour as described above.
Related information
Provide any related information