Skip to content

Commit c89119a

Browse files
authored
Allow an intervening statement in kw prep (#210)
This happens when the call is module-scoped. Fixes JuliaDebug/Debugger.jl#141
1 parent c3854f5 commit c89119a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/commands.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,20 @@ function maybe_step_through_kwprep!(@nospecialize(recurse), frame::Frame, istopl
275275
# We deliberately check isexpr(stmt, :call) rather than is_call(stmt): if it's
276276
# assigned to a local, it's *not* kwarg preparation.
277277
if isexpr(stmt1, :call) && is_quotenode(stmt1.args[1], Core.apply_type) && is_quoted_type(stmt1.args[2], :NamedTuple)
278-
stmt4 = src.code[pc+4]
278+
stmt4, stmt5 = src.code[pc+4], src.code[pc+5]
279279
if isexpr(stmt4, :call) && is_quotenode(stmt4.args[1], Core.kwfunc)
280280
while pc < pccall
281281
pc = step_expr!(recurse, frame, istoplevel)
282282
end
283283
return frame
284+
elseif isexpr(stmt5, :call) && is_quotenode(stmt5.args[1], Core.kwfunc) && pccall+1 <= n
285+
# This happens when the call is scoped by a module
286+
pccall += 1
287+
while pc < pccall
288+
pc = step_expr!(recurse, frame, istoplevel)
289+
end
290+
maybe_next_call!(recurse, frame, istoplevel)
291+
return frame
284292
end
285293
end
286294
end

test/debug.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ struct B{T} end
370370
frame = stepkw!(frame)
371371
@test frame.pc == JuliaInterpreter.nstatements(frame.framecode) - 1
372372

373+
scopedreversesort(x) = Base.sort(x, rev=true) # https://github.com/JuliaDebug/Debugger.jl/issues/141
374+
frame = JuliaInterpreter.enter_call(scopedreversesort, a)
375+
frame = stepkw!(frame)
376+
@test frame.pc == JuliaInterpreter.nstatements(frame.framecode) - 1
377+
373378
frame = JuliaInterpreter.enter_call(sort, a)
374379
frame = stepkw!(frame)
375380
@test frame.pc == JuliaInterpreter.nstatements(frame.framecode) - 1

0 commit comments

Comments
 (0)