Skip to content

Commit

Permalink
Current implementation left out return symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
heetbeet committed Feb 3, 2021
1 parent 5eedacf commit 4b4e091
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/TryCatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,16 @@ module TryCatch
# refactor into proper conditionals
cond, sym = conditionhelper(cond, linenum)

# find-and-repalace error symbol in block
cond = Expr(:block, linenum, cond)
block = Expr(:block, block...)

# find-and-replace the error symbol in block
cond = symbolrename(cond, sym, exception)
block = symbolrename(block, sym, exception)

push!(
conditions,
Expr(:block, linenum, cond) => Expr(:block, block...)
cond => block
)
end
end
Expand Down
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ using Test

@test (@try @catch e @else 2) == 2

@test (@try @catch @else 2) == 2

@test (
@try begin
sqrt("0")
@catch
2
end
) == 2

@test (@try sqrt("0") @catch _ 2) == 2

@test (@try 1) == 1

@test_throws MethodError (@try sqrt("34"))
Expand Down

2 comments on commit 4b4e091

@heetbeet
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/29274

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 4b4e091e1daa7ae6d25a3fa962c5b45288b7b385
git push origin v0.1.0

Please sign in to comment.