Skip to content

Commit df49d29

Browse files
pfitzsebtimholyKristoffer Carlsson
authored
isdefined check in locals() (#396)
* isdefined check in locals() Co-authored-by: Tim Holy <tim.holy@gmail.com> Co-authored-by: Kristoffer Carlsson <kricarl@student.chalmers.se>
1 parent 4d043af commit df49d29

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/utils.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,9 @@ function locals(frame::Frame)
425425
if var.name === Symbol("#self#")
426426
for field in fieldnames(typeof(var.value))
427427
field = field::Symbol
428-
push!(vars, Variable(getfield(var.value, field), field, false, true))
428+
if isdefined(var.value, field)
429+
push!(vars, Variable(getfield(var.value, field), field, false, true))
430+
end
429431
end
430432
end
431433
end

test/interpret.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,3 +640,11 @@ end
640640
D = Diagonal([1.0, 2.0])
641641
@test @interpret(f(D)) === f(D)
642642
end
643+
644+
struct A396
645+
a::Int
646+
end
647+
@testset "constructor locals" begin
648+
frame = JuliaInterpreter.enter_call(A396, 3)
649+
@test length(JuliaInterpreter.locals(frame)) > 0
650+
end

0 commit comments

Comments
 (0)