Skip to content

Commit

Permalink
isdefined check in locals() (#396)
Browse files Browse the repository at this point in the history
* isdefined check  in locals()


Co-authored-by: Tim Holy <[email protected]>
Co-authored-by: Kristoffer Carlsson <[email protected]>
  • Loading branch information
3 people authored Jun 2, 2020
1 parent 4d043af commit df49d29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ function locals(frame::Frame)
if var.name === Symbol("#self#")
for field in fieldnames(typeof(var.value))
field = field::Symbol
push!(vars, Variable(getfield(var.value, field), field, false, true))
if isdefined(var.value, field)
push!(vars, Variable(getfield(var.value, field), field, false, true))
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions test/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -640,3 +640,11 @@ end
D = Diagonal([1.0, 2.0])
@test @interpret(f(D)) === f(D)
end

struct A396
a::Int
end
@testset "constructor locals" begin
frame = JuliaInterpreter.enter_call(A396, 3)
@test length(JuliaInterpreter.locals(frame)) > 0
end

0 comments on commit df49d29

Please sign in to comment.