Skip to content

Commit

Permalink
Allow an intervening statement in kw prep
Browse files Browse the repository at this point in the history
This happens when the call is module-scoped.
Fixes JuliaDebug/Debugger.jl#141
  • Loading branch information
timholy committed Mar 24, 2019
1 parent c3854f5 commit 73a9156
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,20 @@ function maybe_step_through_kwprep!(@nospecialize(recurse), frame::Frame, istopl
# We deliberately check isexpr(stmt, :call) rather than is_call(stmt): if it's
# assigned to a local, it's *not* kwarg preparation.
if isexpr(stmt1, :call) && is_quotenode(stmt1.args[1], Core.apply_type) && is_quoted_type(stmt1.args[2], :NamedTuple)
stmt4 = src.code[pc+4]
stmt4, stmt5 = src.code[pc+4], src.code[pc+5]
if isexpr(stmt4, :call) && is_quotenode(stmt4.args[1], Core.kwfunc)
while pc < pccall
pc = step_expr!(recurse, frame, istoplevel)
end
return frame
elseif isexpr(stmt5, :call) && is_quotenode(stmt5.args[1], Core.kwfunc) && pccall+1 <= n
# This happens when the call is scoped by a module
pccall += 1
while pc < pccall
pc = step_expr!(recurse, frame, istoplevel)
end
maybe_next_call!(recurse, frame, istoplevel)
return frame
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ struct B{T} end
frame = stepkw!(frame)
@test frame.pc == JuliaInterpreter.nstatements(frame.framecode) - 1

scopedreversesort(x) = Base.sort(x, rev=true) # https://github.com/JuliaDebug/Debugger.jl/issues/141
frame = JuliaInterpreter.enter_call(scopedreversesort, a)
frame = stepkw!(frame)
@test frame.pc == JuliaInterpreter.nstatements(frame.framecode) - 1

frame = JuliaInterpreter.enter_call(sort, a)
frame = stepkw!(frame)
@test frame.pc == JuliaInterpreter.nstatements(frame.framecode) - 1
Expand Down

0 comments on commit 73a9156

Please sign in to comment.