Skip to content

Commit 42a2912

Browse files
committed
Fix the return value of atsign-interpret (fixes #168)
1 parent ad91dd9 commit 42a2912

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/construct.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -630,15 +630,15 @@ macro interpret(arg)
630630
return :(throw($e))
631631
end
632632
quote
633-
theargs = $(esc(args))
634-
frame = JuliaInterpreter.enter_call_expr(Expr(:call, theargs...))
633+
local theargs = $(esc(args))
634+
local frame = JuliaInterpreter.enter_call_expr(Expr(:call, theargs...))
635635
if frame === nothing
636-
return eval(Expr(:call, map(QuoteNode, theargs)...))
637-
end
638-
if shouldbreak(frame, 1)
639-
return frame, BreakpointRef(frame.framecode, 1)
636+
eval(Expr(:call, map(QuoteNode, theargs)...))
637+
elseif shouldbreak(frame, 1)
638+
frame, BreakpointRef(frame.framecode, 1)
639+
else
640+
local ret = finish_and_return!(frame)
641+
isa(ret, BreakpointRef) ? (frame, ret) : ret
640642
end
641-
ret = finish_and_return!(frame)
642-
isa(ret, BreakpointRef) ? (frame, ret) : ret
643643
end
644644
end

test/breakpoints.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ end
8181
disable(bp)
8282
@test JuliaInterpreter.finish_stack!(frame) == loop_radius2(10)
8383

84+
# Return value with breakpoints
85+
@breakpoint sum([1,2]) any(x->x>4, a)
86+
val = @interpret sum([1,2,3])
87+
@test val == 6
88+
frame, bp = @interpret sum([1,2,5])
89+
@test isa(frame, Frame) && isa(bp, JuliaInterpreter.BreakpointRef)
90+
8491
# Next line with breakpoints
8592
function outer(x)
8693
inner(x)

0 commit comments

Comments
 (0)