Skip to content

Commit 4976a36

Browse files
authored
fix undef sparam in locals (#201)
1 parent 3bce6a9 commit 4976a36

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/utils.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ function locals(frame::Frame)
303303
if code.scope isa Method
304304
syms = sparam_syms(code.scope)
305305
for i in 1:length(syms)
306-
push!(vars, Variable(data.sparams[i], syms[i], true))
306+
if isassigned(data.sparams, i)
307+
push!(vars, Variable(data.sparams[i], syms[i], true))
308+
end
307309
end
308310
end
309311
return vars

test/interpret.jl

+5
Original file line numberDiff line numberDiff line change
@@ -413,3 +413,8 @@ e = try
413413
end
414414
@test e isa UndefVarError
415415
@test e.var == :S
416+
# https://github.com/JuliaDebug/JuliaInterpreter.jl/issues/200
417+
locs = JuliaInterpreter.locals(JuliaInterpreter.enter_call(foo, ""))
418+
@test length(locs) == 3 # #self# + 2 variables
419+
@test JuliaInterpreter.Variable("", :x, false) in locs
420+
@test JuliaInterpreter.Variable(String, :T, true) in locs

0 commit comments

Comments
 (0)