diff --git a/base/rational.jl b/base/rational.jl index b27baf5973d3b1..bd1633bd3dd28f 100644 --- a/base/rational.jl +++ b/base/rational.jl @@ -315,8 +315,6 @@ denominator(x::Rational) = x.den sign(x::Rational) = oftype(x, sign(x.num)) signbit(x::Rational) = signbit(x.num) -copysign(x::Rational, y::Real) = unsafe_rational(copysign(x.num, y), x.den) -copysign(x::Rational, y::Rational) = unsafe_rational(copysign(x.num, y.num), x.den) abs(x::Rational) = unsafe_rational(checked_abs(x.num), x.den) diff --git a/test/numbers.jl b/test/numbers.jl index 922fa0da3337e5..47d7e87753b112 100644 --- a/test/numbers.jl +++ b/test/numbers.jl @@ -679,6 +679,9 @@ end @test copysign(big(-1), 0x02) == 1 @test copysign(big(-1.0), 0x02) == 1.0 @test copysign(-1//2, 0x01) == 1//2 + + # Verify overflow is checked with rational + @test_throws OverflowError copysign(typemin(Int)//1, 1) end @testset "isnan/isinf/isfinite" begin