From 7be90097b2868b56280e16d3095561011db0d536 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 | 4 ++-- 3 files changed, 14 insertions(+), 9 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..ef5d989e322d5 100644 --- a/base/promotion.jl +++ b/base/promotion.jl @@ -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)