Skip to content

Commit

Permalink
leq for reals falls back to le and eq (#46341)
Browse files Browse the repository at this point in the history
(cherry picked from commit ef511c9)
  • Loading branch information
jishnub authored and KristofferC committed Aug 17, 2022
1 parent 5544a0f commit 27890c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/promotion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ xor(x::T, y::T) where {T<:Integer} = no_op_err("xor", T)

(==)(x::T, y::T) where {T<:Number} = x === y
(< )(x::T, y::T) where {T<:Real} = no_op_err("<" , T)
(<=)(x::T, y::T) where {T<:Real} = no_op_err("<=", T)
(<=)(x::T, y::T) where {T<:Real} = (x == y) | (x < y)

rem(x::T, y::T) where {T<:Real} = no_op_err("rem", T)
mod(x::T, y::T) where {T<:Real} = no_op_err("mod", T)
Expand Down
11 changes: 11 additions & 0 deletions test/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,14 @@ end
@test Returns(val)(1) === val
@test sprint(show, Returns(1.0)) == "Returns{Float64}(1.0)"
end

@testset "<= (issue #46327)" begin
struct A46327 <: Real end
Base.:(==)(::A46327, ::A46327) = false
Base.:(<)(::A46327, ::A46327) = false
@test !(A46327() <= A46327())
struct B46327 <: Real end
Base.:(==)(::B46327, ::B46327) = true
Base.:(<)(::B46327, ::B46327) = false
@test B46327() <= B46327()
end

0 comments on commit 27890c7

Please sign in to comment.