RelationalAI-oss / Rematch.jl

Pattern matching
Other
52 stars 6 forks source link

Rematch should probably use `isequal` instead of `==` for floating-point types #35

Open gafter opened 1 year ago

gafter commented 1 year ago

This:

using Rematch
nan = 0.0 / 0.0
f(x) = @match x begin
    [a,a] => :same
    [a,b] => :different
    _ => :other
end
println(f([nan, nan]))

prints "different".

jerlich commented 1 year ago

https://discourse.julialang.org/t/various-equalities-of-nan/42649

gafter commented 1 year ago

@jerlich I assume you provided that link in support of the bug report?

FYI, there is a revision of this package at https://github.com/JuliaServices/Rematch2.jl that I am preparing as a new release of https://github.com/JuliaServices/Match.jl. It addresses this any many other issues in both Match.jl and Rematch.jl.

jerlich commented 1 year ago

Yes. That discourse discussion explains why Nan don't always equal nan.