# Debugging constructors

**URL:** <https://discourse.julialang.org/t/debugging-constructors/40221>\
**Category:** Tooling\
**Tags:** question, juno, debug\
**Created:** [May 26, 2020, 9:38pm UTC](https://discourse.julialang.org/t/debugging-constructors/40221 "2020-05-26T21:38:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryce](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bryce/32/15193_2.png) [@bryce](https://discourse.julialang.org/u/bryce)\
**Post date:** [May 26, 2020, 9:38pm UTC](https://discourse.julialang.org/t/debugging-constructors/40221/1 "2020-05-26T21:38:59Z")

</div>

I’m trying to use the debugger in Juno, and it fails with an UndefRefError if I set a breakpoint inside a constructor. Does anyone have any idea why this is happening or what I can do about it? Here’s a minimal example:

```julia
struct A
    a::Int
end

function A()
    a = 2
    A(a)
end

function B()
    a = 2
    A(a)
end

println(A().a)
println(B().a)

```

If I run without the debugger, it correctly prints 2 twice. When I set a breakpoint on line 12 (the last statement in function B), the debugger behaves correctly and I can inspect local variables. When I set a breakpoint on line 7 (the last statement in function A), the debugger errors and won’t let me inspect anything (neither in the workspace nor the REPL). Here’s the full text of the error:

```julia
Julia Client – Internal Error

UndefRefError: access to undefined reference
locals(::JuliaInterpreter.Frame) at utils.jl:428
localvars(::JuliaInterpreter.Frame) at workspace.jl:22
contexts(::Atom.JunoDebugger.DebuggerState) at workspace.jl:13
contexts at workspace.jl:5 [inlined]
workspace(::String) at workspace.jl:9
handlemsg(::Dict{String,Any}, ::String) at comm.jl:169
(::Atom.var"#31#33"{Array{Any,1}})() at task.jl:358

```

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [May 27, 2020, 11:18am UTC](https://discourse.julialang.org/t/debugging-constructors/40221/2 "2020-05-27T11:18:00Z")

</div>

Thanks for the report! Should be fixed by

> <https://github.com/JuliaDebug/JuliaInterpreter.jl/pull/396>
>
> ~~Not sure how to best test this though.~~ Now with tests.
