Skip to content

Commit

Permalink
Automatically step through kw wrappers
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
Keno committed Nov 11, 2017
1 parent 43bf12e commit 5ebe035
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/ASTInterpreter2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ end
function maybe_step_through_wrapper!(stack)
last = stack[1].code.code[end-1]
isexpr(last, :(=)) && (last = last.args[2])
if isexpr(last, :call) && any(x->x==SlotNumber(1), last.args)
is_kw = startswith(String(Base.unwrap_unionall(stack[1].meth.sig).parameters[1].name.name), "#kw")
if is_kw || isexpr(last, :call) && any(x->x==SlotNumber(1), last.args)
# If the last expr calls #self# or passes it to an implemetnation method,
# this is a wrapper function that we might want to step though
frame = stack[1]
Expand Down
12 changes: 11 additions & 1 deletion test/stepping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,14 @@ execute_command(state, state.stack[1], Val{:n}(), "n")
execute_command(state, state.stack[1], Val{:finish}(), "finish")
execute_command(state, state.stack[1], Val{:finish}(), "finish")
@assert isempty(state.stack)
@assert state.overall_result == 2
@assert state.overall_result == 2

# Test that we step through kw wrappers
f(foo; bar=3) = foo+bar
stack = @make_stack f(2, bar=4)
@assert length(stack) > 1
state = dummy_state(stack)
execute_command(state, state.stack[1], Val{:n}(), "nc")
execute_command(state, state.stack[1], Val{:n}(), "nc")
@assert isempty(state.stack)
@assert state.overall_result == 6

0 comments on commit 5ebe035

Please sign in to comment.