Skip to content

Commit

Permalink
Fixes for Julia 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Jul 19, 2018
1 parent 6c565a3 commit 1eeb991
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
julia 0.6
Compat 0.60.0
6 changes: 4 additions & 2 deletions src/Retry.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
__precompile__(true)

module Retry

__precompile__(true)
using Compat

export @repeat, @protected, efield, ecode

efield(x, f, default=nothing) = f in fieldnames(x) ? getfield(x, f) : default
efield(x, f, default=nothing) = f in fieldnames(typeof(x)) ? getfield(x, f) : default
ecode(x) = efield(x, :code)

include("repeat_try.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/protected_try.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ macro protected(try_expr::Expr)
end

# Check for nothing exception at start of catch block...
unshift!(catch_block.args, :($exception == nothing && rethrow($exception)))
pushfirst!(catch_block.args, :($exception == nothing && rethrow($exception)))

# Check rethrow flag at end of catch block...
push!(catch_block.args, :($exception == nothing || rethrow($exception)))
Expand Down
4 changes: 2 additions & 2 deletions src/repeat_try.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ macro repeat(max, try_expr::Expr)

# Replace @ignore/@retry macro call with modified if expression...
catch_block.args[i] = if_expr
elseif expr.head != :line
elseif !isa(expr, LineNumberNode) || (isa(expr, Expr) && expr.head != :line)
catch_block.args[i] = esc(expr)
end
end

# Check for nothing exception at start of catch block...
insert!(catch_block.args, 2, :($exception == nothing && rethrow()))
unshift!(catch_block.args, :(ignore = false))
pushfirst!(catch_block.args, :(ignore = false))

# Rethrow at end of catch block...
push!(catch_block.args, :(ignore || rethrow($exception)))
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@


using Retry
using Base.Test
using Compat
using Compat.Test


mutable struct TestException <: Exception
Expand Down

0 comments on commit 1eeb991

Please sign in to comment.