diff --git a/base/special/gamma.jl b/base/special/gamma.jl index 2a3e4bb463811..a322d92adb9b9 100644 --- a/base/special/gamma.jl +++ b/base/special/gamma.jl @@ -640,7 +640,7 @@ for f in (:digamma, :trigamma, :zeta, :eta, :invdigamma) function $f(z::Number) x = float(z) - typeof(x) == typeof(z) && throw(MethodError($f, (z,))) + typeof(x) === typeof(z) && throw(MethodError($f, (z,))) # There is nothing to fallback to, since this didn't change the argument types $f(x) end @@ -675,22 +675,22 @@ function zeta(s::Complex{Int}, z::ComplexOrReal{Float64})::Complex{Float64} end function zeta(s::Integer, z::Number) - x = float(z) t = Int(s) # One could worry here about converting a BigInteger into a Int32/Int64 - if typeof(x) === typeof(z) && typeof(t) === typeof(s) + x = float(z) + if typeof(t) === typeof(s) && typeof(x) === typeof(z) # There is nothing to fallback to, since this didn't work - throw(MethodError(zeta,(s,t))) + throw(MethodError(zeta,(s,z))) end zeta(t, x) end function zeta(s::Number, z::Number) - x = float(z) t = float(s) - if typeof(x) === typeof(z) && typeof(t) === typeof(s) + x = float(z) + if typeof(t) === typeof(s) && typeof(x) === typeof(z) # There is nothing to fallback to, since this didn't work - throw(MethodError(zeta,(s,t))) + throw(MethodError(zeta,(s,z))) end zeta(t, x) end @@ -698,7 +698,7 @@ end function polygamma(m::Integer, z::Number) x = float(z) - typeof(x) == typeof(z) && throw(MethodError(polygamma, (m,z))) + typeof(x) === typeof(z) && throw(MethodError(polygamma, (m,z))) # There is nothing to fallback to, since this didn't work polygamma(m, x) end diff --git a/test/math.jl b/test/math.jl index b22fb5f6864b7..bbc6b8faebb7d 100644 --- a/test/math.jl +++ b/test/math.jl @@ -948,11 +948,22 @@ end @test typeof(eta(big"2")) == BigFloat @test typeof(zeta(big"2")) == BigFloat @test typeof(digamma(big"2")) == BigFloat + @test_throws MethodError trigamma(big"2") @test_throws MethodError trigamma(big"2.0") @test_throws MethodError invdigamma(big"2") @test_throws MethodError invdigamma(big"2.0") + @test_throws MethodError eta(Complex(big"2")) @test_throws MethodError eta(Complex(big"2.0")) @test_throws MethodError zeta(Complex(big"2")) @test_throws MethodError zeta(Complex(big"2.0")) +@test_throws MethodError zeta(1.0,big"2") +@test_throws MethodError zeta(1.0,big"2.0") +@test_throws MethodError zeta(big"1.0",2.0) + +@test typeof(zeta(complex(1),2.0)) == Complex{Float64} +@test typeof(polygamma(3, 0x2)) == Float64 +@test typeof(polygamma(big"3", 2f0)) == Float32 +@test typeof(zeta(big"1",2.0)) == Float64 #Is this really desirable behavour? +