Skip to content

Commit 904b1e0

Browse files
Merge branch 'master' into jldoctest-fix
2 parents 7cbd3a8 + 6817691 commit 904b1e0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

base/math.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ for f in (:sin, :cos, :tan, :asin, :atan, :acos,
15421542
:exponent, :sqrt, :cbrt, :sinpi, :cospi, :sincospi, :tanpi)
15431543
@eval function ($f)(x::Real)
15441544
xf = float(x)
1545-
x === xf && throw(MethodError($f, (x,)))
1545+
xf isa typeof(x) && throw(MethodError($f, (x,)))
15461546
return ($f)(xf)
15471547
end
15481548
@eval $(f)(::Missing) = missing

test/math.jl

+8
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,14 @@ end
15491549
end
15501550
end
15511551

1552+
@testset "special function `::Real` fallback shouldn't recur without bound, issue #57789" begin
1553+
mutable struct Issue57789 <: Real end
1554+
Base.float(::Issue57789) = Issue57789()
1555+
for f (sin, sinpi, log, exp)
1556+
@test_throws MethodError f(Issue57789())
1557+
end
1558+
end
1559+
15521560
# Test that sqrt behaves correctly and doesn't exhibit fp80 double rounding.
15531561
# This happened on old glibc versions.
15541562
# Test case from https://sourceware.org/bugzilla/show_bug.cgi?id=14032.

0 commit comments

Comments
 (0)