diff --git a/src/utils.jl b/src/utils.jl index ff7fe826494fa..d54c11a8788d1 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -303,7 +303,9 @@ function locals(frame::Frame) if code.scope isa Method syms = sparam_syms(code.scope) for i in 1:length(syms) - push!(vars, Variable(data.sparams[i], syms[i], true)) + if isassigned(data.sparams, i) + push!(vars, Variable(data.sparams[i], syms[i], true)) + end end end return vars diff --git a/test/interpret.jl b/test/interpret.jl index 4200899242a6e..c37c264edeca1 100644 --- a/test/interpret.jl +++ b/test/interpret.jl @@ -413,3 +413,8 @@ e = try end @test e isa UndefVarError @test e.var == :S +# https://github.com/JuliaDebug/JuliaInterpreter.jl/issues/200 +locs = JuliaInterpreter.locals(JuliaInterpreter.enter_call(foo, "")) +@test length(locs) == 3 # #self# + 2 variables +@test JuliaInterpreter.Variable("", :x, false) in locs +@test JuliaInterpreter.Variable(String, :T, true) in locs \ No newline at end of file