From 07ae32c3c828d7c25cf7f376122a3d65624e4077 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Tue, 8 Aug 2017 17:14:13 -0500 Subject: [PATCH 1/2] Add support for multiarg InexactError, DomainError, OverflowError --- README.md | 5 +++++ src/Compat.jl | 16 ++++++++++++++++ test/runtests.jl | 10 ++++++++++ 3 files changed, 31 insertions(+) diff --git a/README.md b/README.md index dfc1a923a..8503500f5 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `fieldcount` is equivalent to `nfields` for Julia versions 0.6 and below and is used to determine the number of fields in a data type ([#22350]). +* There are versions of `InexactError`, `DomainError`, and `OverflowError` that take the same arguments as introduced in Julia 0.7-DEV ([#20005], [#22751], [#22761]). + ## Renamed functions @@ -311,6 +313,7 @@ includes this fix. Find the minimum version from there. [#20974]: https://github.com/JuliaLang/julia/issues/20974 [#21257]: https://github.com/JuliaLang/julia/issues/21257 [#21346]: https://github.com/JuliaLang/julia/issues/21346 +[#22005]: https://github.com/JuliaLang/julia/issues/22005 [#22064]: https://github.com/JuliaLang/julia/issues/22064 [#22182]: https://github.com/JuliaLang/julia/issues/22182 [#22350]: https://github.com/JuliaLang/julia/issues/22350 @@ -318,4 +321,6 @@ includes this fix. Find the minimum version from there. [#22633]: https://github.com/JuliaLang/julia/issues/22633 [#22629]: https://github.com/JuliaLang/julia/issues/22629 [#22666]: https://github.com/JuliaLang/julia/pull/22666 +[#22751]: https://github.com/JuliaLang/julia/pull/22751 +[#22761]: https://github.com/JuliaLang/julia/pull/22761 [#22864]: https://github.com/JuliaLang/julia/pull/22864 diff --git a/src/Compat.jl b/src/Compat.jl index c06d4e86e..2cba3246f 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -488,6 +488,22 @@ if VERSION < v"0.7.0-DEV.1053" Base.read(obj::Cmd, ::Type{String}) = readstring(obj) end +# https://github.com/JuliaLang/julia/pull/20005 +if VERSION < v"0.7.0-DEV.896" + Base.InexactError(name::Symbol, T, val) = InexactError() +end + +# https://github.com/JuliaLang/julia/pull/22751 +if VERSION < v"0.7.0-DEV.924" + Base.DomainError(val) = DomainError() + Base.DomainError(val, msg) = DomainError() +end + +# https://github.com/JuliaLang/julia/pull/222761 +if VERSION < v"0.7.0-DEV.1285" + Base.OverflowError(msg) = OverflowError() +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index efa8bc81a..bc0099145 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -658,6 +658,16 @@ eval(Expr(:type, false, :TestType, Expr(:block, :(a::Int), :b))) @test fieldcount(TestType) == 2 @test fieldcount(Int) == 0 +# PR 20005 +@test_throws InexactError throw(InexactError(:func, Int, 3.2)) + +# PR 22751 +@test_throws DomainError throw(DomainError(-2)) +@test_throws DomainError throw(DomainError(-2, "negative")) + +# PR 22761 +@test_throws OverflowError throw(OverflowError("overflow")) + let x = fill!(StringVector(5), 0x61) # 0.7 @test pointer(x) == pointer(String(x)) From 7556fc3d528f0d3b8af816ce91927d19949287fc Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Tue, 8 Aug 2017 16:21:07 -0700 Subject: [PATCH 2/2] delete a tripled-2 that should have only been doubled [ci skip] --- src/Compat.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compat.jl b/src/Compat.jl index 2cba3246f..3c323316e 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -499,7 +499,7 @@ if VERSION < v"0.7.0-DEV.924" Base.DomainError(val, msg) = DomainError() end -# https://github.com/JuliaLang/julia/pull/222761 +# https://github.com/JuliaLang/julia/pull/22761 if VERSION < v"0.7.0-DEV.1285" Base.OverflowError(msg) = OverflowError() end