From 1e9c658c14ed8b5584b666aa864ad02e2a2fbc6b Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 24 Feb 2017 16:49:58 -0500 Subject: [PATCH] break some dependency backedges This would be nicer if we had function types, but this tries to at least hit a couple of the high points fix #20780 --- base/deprecated.jl | 1 + base/operators.jl | 18 +++++++++++------- base/promotion.jl | 10 +++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/base/deprecated.jl b/base/deprecated.jl index 9ecfd1843f90f..36fc639baa403 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -826,6 +826,7 @@ end # Deprecate vectorized ! @deprecate(!(A::AbstractArray{Bool}), .!A) # parens for #20541 @deprecate(!(B::BitArray), .!B) # parens for #20541 +!(::typeof(()->())) = () # make sure ! has at least 4 methods so that for-loops don't end up getting a back-edge to depwarn # Deprecate vectorized ~ @deprecate ~(A::AbstractArray) .~A diff --git a/base/operators.jl b/base/operators.jl index 29e90e5890b88..bd8eceffbe108 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -86,13 +86,17 @@ false """ isequal(x, y) = x == y -isequal(x::AbstractFloat, y::AbstractFloat) = (isnan(x) & isnan(y)) | (signbit(x) == signbit(y)) & (x == y) -isequal(x::Real, y::AbstractFloat) = (isnan(x) & isnan(y)) | (signbit(x) == signbit(y)) & (x == y) -isequal(x::AbstractFloat, y::Real ) = (isnan(x) & isnan(y)) | (signbit(x) == signbit(y)) & (x == y) +signequal(x, y) = signbit(x)::Bool == signbit(y)::Bool +signless(x, y) = signbit(x)::Bool & !signbit(y)::Bool + +isequal(x::AbstractFloat, y::AbstractFloat) = (isnan(x) & isnan(y)) | signequal(x, y) & (x == y) +isequal(x::Real, y::AbstractFloat) = (isnan(x) & isnan(y)) | signequal(x, y) & (x == y) +isequal(x::AbstractFloat, y::Real ) = (isnan(x) & isnan(y)) | signequal(x, y) & (x == y) + +isless(x::AbstractFloat, y::AbstractFloat) = (!isnan(x) & isnan(y)) | signless(x, y) | (x < y) +isless(x::Real, y::AbstractFloat) = (!isnan(x) & isnan(y)) | signless(x, y) | (x < y) +isless(x::AbstractFloat, y::Real ) = (!isnan(x) & isnan(y)) | signless(x, y) | (x < y) -isless(x::AbstractFloat, y::AbstractFloat) = (!isnan(x) & isnan(y)) | (signbit(x) & !signbit(y)) | (x < y) -isless(x::Real, y::AbstractFloat) = (!isnan(x) & isnan(y)) | (signbit(x) & !signbit(y)) | (x < y) -isless(x::AbstractFloat, y::Real ) = (!isnan(x) & isnan(y)) | (signbit(x) & !signbit(y)) | (x < y) function ==(T::Type, S::Type) @_pure_meta @@ -122,7 +126,7 @@ julia> "foo" ≠ "foo" false ``` """ -!=(x, y) = !(x == y) +!=(x, y) = !(x == y)::Bool const ≠ = != """ diff --git a/base/promotion.jl b/base/promotion.jl index 98efd35b044a3..2cf52f92ad463 100644 --- a/base/promotion.jl +++ b/base/promotion.jl @@ -282,9 +282,9 @@ muladd(x::Number, y::Number, z::Number) = muladd(promote(x,y,z)...) (|)(x::Integer, y::Integer) = (|)(promote(x,y)...) xor(x::Integer, y::Integer) = xor(promote(x,y)...) -==(x::Number, y::Number) = (==)(promote(x,y)...) -<( x::Real, y::Real) = (< )(promote(x,y)...) -<=(x::Real, y::Real) = (<=)(promote(x,y)...) +==(x::Number, y::Number) = (==)(promote(x,y)...)::Bool +<( x::Real, y::Real) = (< )(promote(x,y)...)::Bool +<=(x::Real, y::Real) = (<=)(promote(x,y)...)::Bool div(x::Real, y::Real) = div(promote(x,y)...) fld(x::Real, y::Real) = fld(promote(x,y)...) @@ -352,6 +352,6 @@ min(x::Real) = x max(x::Real) = x minmax(x::Real) = (x, x) -max{T<:Real}(x::T, y::T) = ifelse(y < x, x, y) -min{T<:Real}(x::T, y::T) = ifelse(y < x, y, x) +max{T<:Real}(x::T, y::T) = select_value(y < x, x, y) +min{T<:Real}(x::T, y::T) = select_value(y < x, y, x) minmax{T<:Real}(x::T, y::T) = y < x ? (y, x) : (x, y)