Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of duplicate slotnames #486

Merged
merged 4 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/breakpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,15 @@ end

function prepare_slotfunction(framecode::FrameCode, body::Union{Symbol,Expr})
uslotnames = Set{Symbol}()
slotnames = Symbol[]
for name in framecode.src.slotnames
if name ∉ uslotnames
push!(slotnames, name)
push!(uslotnames, name)
end
end
framename, dataname = gensym("frame"), gensym("data")
assignments = Expr[:($dataname = $framename.framedata)]
default = Unassigned()
for i = 1:length(slotnames)
slotname = framecode.src.slotnames[i]
qslotname = QuoteNode(slotname)
for slotname in framecode.src.slotnames
if slotname ∉ uslotnames
push!(uslotnames, slotname)
else
continue
end
list = framecode.slotnamelists[slotname]
if length(list) == 1
maxexpr = :($dataname.last_reference[$(list[1])] > 0 ? $(list[1]) : 0)
Expand Down
28 changes: 28 additions & 0 deletions test/breakpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,31 @@ empty!(breakpoint_update_hooks)
remove()
end
end

@testset "duplicate slotnames" begin
tmp_dupl() = (1,2,3,4)
ln = @__LINE__
function duplnames(x)
for iter in Iterators.CartesianIndices(x)
i = iter[1]
c = i
a, b, c, d = tmp_dupl()
end
return x
end
bp = breakpoint(@__FILE__, ln+5, :(i == 1))
c = @code_lowered(duplnames((1,2)))
if length(unique(c.slotnames)) < length(c.slotnames)
f = JuliaInterpreter.enter_call(duplnames, (1,2))
ex = JuliaInterpreter.prepare_slotfunction(f.framecode, :(i==1))
@test ex isa Expr
found = false
for arg in ex.args[end].args
if arg.args[1] == :i
found = true
end
end
@test found
@test last(JuliaInterpreter.debug_command(f, :c)) isa BreakpointRef
end
end