Skip to content

Commit cf126a1

Browse files
committed
improve handling of duplicate slotnames
1 parent 8e7bac9 commit cf126a1

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

src/breakpoints.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,18 @@ end
189189

190190
function prepare_slotfunction(framecode::FrameCode, body::Union{Symbol,Expr})
191191
uslotnames = Set{Symbol}()
192-
slotnames = Symbol[]
193-
for name in framecode.src.slotnames
194-
if name uslotnames
195-
push!(slotnames, name)
196-
push!(uslotnames, name)
197-
end
198-
end
199192
framename, dataname = gensym("frame"), gensym("data")
200193
assignments = Expr[:($dataname = $framename.framedata)]
201194
default = Unassigned()
202-
for i = 1:length(slotnames)
203-
slotname = framecode.src.slotnames[i]
204-
qslotname = QuoteNode(slotname)
195+
for slotname in framecode.src.slotnames
196+
if slotname === Symbol("")
197+
continue
198+
end
199+
if slotname uslotnames
200+
push!(uslotnames, slotname)
201+
else
202+
continue
203+
end
205204
list = framecode.slotnamelists[slotname]
206205
if length(list) == 1
207206
maxexpr = :($dataname.last_reference[$(list[1])] > 0 ? $(list[1]) : 0)

test/breakpoints.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,25 @@ empty!(breakpoint_update_hooks)
433433
remove()
434434
end
435435
end
436+
437+
@testset "duplicate slotnames" begin
438+
tmp_dupl() = (1,2,3,4)
439+
ln = @__LINE__
440+
function duplnames(x)
441+
for iter in Iterators.CartesianIndices(x)
442+
i = iter[1]
443+
c = i
444+
a, b, c, d = tmp_dupl()
445+
end
446+
return x
447+
end
448+
bp = breakpoint(@__FILE__, ln+5, :(i == 1))
449+
c = @code_lowered(duplnames((1,2)))
450+
if length(unique(c.slotnames)) < length(c.slotnames)
451+
f = JuliaInterpreter.enter_call(duplnames, (1,2))
452+
ex = JuliaInterpreter.prepare_slotfunction(f.framecode, :(i==1))
453+
@test ex isa Expr
454+
@test ex.args[end].args[end-1].args[1] == :i
455+
@test last(JuliaInterpreter.debug_command(f, :c)) isa BreakpointRef
456+
end
457+
end

0 commit comments

Comments
 (0)