Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ for f in (:sin, :cos, :tan, :asin, :atan, :acos,
:exponent, :sqrt, :cbrt, :sinpi, :cospi, :sincospi, :tanpi)
@eval function ($f)(x::Real)
xf = float(x)
x === xf && throw(MethodError($f, (x,)))
xf isa typeof(x) && throw(MethodError($f, (x,)))
return ($f)(xf)
end
@eval $(f)(::Missing) = missing
Expand Down
8 changes: 8 additions & 0 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,14 @@ end
end
end

@testset "special function `::Real` fallback shouldn't recur without bound, issue #57789" begin
mutable struct Issue57789 <: Real end
Base.float(::Issue57789) = Issue57789()
for f ∈ (sin, sinpi, log, exp)
@test_throws MethodError f(Issue57789())
end
end

# Test that sqrt behaves correctly and doesn't exhibit fp80 double rounding.
# This happened on old glibc versions.
# Test case from https://sourceware.org/bugzilla/show_bug.cgi?id=14032.
Expand Down