From 212d7279b929407f221b6a8ae6ee7b1181652f08 Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Sat, 18 Oct 2025 22:32:01 +0200 Subject: [PATCH 1/2] Type-assert `isfinite(::AbstractFloat)` Currently it's inferred as `Any` because of the subtraction operation. --- base/float.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/float.jl b/base/float.jl index f3dab99258cd8..586eca6a8e9ab 100644 --- a/base/float.jl +++ b/base/float.jl @@ -708,7 +708,7 @@ See also: [`iszero`](@ref), [`isone`](@ref), [`isinf`](@ref), [`ismissing`](@ref isnan(x::AbstractFloat) = (x != x)::Bool isnan(x::Number) = false -isfinite(x::AbstractFloat) = !isnan(x - x) +isfinite(x::AbstractFloat) = (!isnan(x - x))::Bool isfinite(x::Real) = decompose(x)[3] != 0 isfinite(x::Integer) = true From 5dd00a927e458ef84ced8438defbaf58f4a0ad9e Mon Sep 17 00:00:00 2001 From: James Wrigley Date: Sun, 19 Oct 2025 10:31:21 +0200 Subject: [PATCH 2/2] Update base/float.jl Co-authored-by: Simeon David Schaub --- base/float.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/float.jl b/base/float.jl index 586eca6a8e9ab..0ed55b4902194 100644 --- a/base/float.jl +++ b/base/float.jl @@ -708,7 +708,7 @@ See also: [`iszero`](@ref), [`isone`](@ref), [`isinf`](@ref), [`ismissing`](@ref isnan(x::AbstractFloat) = (x != x)::Bool isnan(x::Number) = false -isfinite(x::AbstractFloat) = (!isnan(x - x))::Bool +isfinite(x::AbstractFloat) = !(isnan(x - x)::Bool) isfinite(x::Real) = decompose(x)[3] != 0 isfinite(x::Integer) = true