Skip to content

Commit

Permalink
Merge pull request #393 from JuliaLang/teh/error_args
Browse files Browse the repository at this point in the history
Add support for multiarg InexactError, DomainError, OverflowError
  • Loading branch information
timholy authored Aug 9, 2017
2 parents 8281370 + 7556fc3 commit 4f24102
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -311,11 +313,14 @@ 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
[#22475]: https://github.com/JuliaLang/julia/issues/22475
[#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
16 changes: 16 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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/22761
if VERSION < v"0.7.0-DEV.1285"
Base.OverflowError(msg) = OverflowError()
end

include("deprecated.jl")

end # module Compat
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4f24102

Please sign in to comment.