Inconsistant equality for objects containing NaN
Opened this issue · 0 comments
harrysarson commented
If two (different) identical objects contains NaN
the full structured equality finds them to be different.
However, if an object containing NaN
is compared with itself the shortcut reference equality means that the (==)
operator returns true.
The following also works with records, union types, etc as well as lists.
SSCCE (https://ellie-app.com/3jTfFrpjNbJa1)
module Main exposing (main)
import Html exposing (Html, button, div, text)
nan1 = [ 0/0 ]
nan2 = [ 0/0 ]
main : Html never
main =
div
[]
[ div [] [ text <| "nan1 == nan1 -- " ++ (Debug.toString (nan1 == nan1)) ]
, div [] [ text <| "nan1 == nan2 -- " ++ (Debug.toString (nan1 == nan2)) ]
]
Output
nan1 == nan1 -- True
nan1 == nan2 -- False
Problem
The result is inconsistent. Both equalities should either evaluate as True
or False
and be consistent with each other.