# Get UndefRefError, when step into function

**URL:** https://discourse.julialang.org/t/get-undefreferror-when-step-into-function/30909
**Category:** General Usage
**Tags:** question
**Created:** [November 10, 2019, 3:06am UTC](https://discourse.julialang.org/t/get-undefreferror-when-step-into-function/30909 "2019-11-10T03:06:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nick-stu](https://avatars.discourse-cdn.com/v4/letter/n/858c86/32.png) [@nick-stu](https://discourse.julialang.org/u/nick-stu)
#### Post date: [November 10, 2019, 3:06am UTC](https://discourse.julialang.org/t/get-undefreferror-when-step-into-function/30909/1 "2019-11-10T03:06:14Z")

</div>

> ubuntu 16.04.5  
> julia 0.6.4  
> atom 1.41.0

Hi all, I am new to julia. I try to run and debug the code “test/runtests.jl” from [GitHub - jgorham/SteinDiscrepancy.jl: Practical tools for quantifying how well a sample approximates a target distribution](https://github.com/jgorham/SteinDiscrepancy.jl)(I mainly want to single-line debug this code and study how it works.)  
I have reviewed the relevant documentation, including [Debugging · Juno Documentation](https://docs.junolab.org/latest/man/debugging/)

“test/runtests.jl” can run successfully,

In addition, because juno does not support debugging the non-function file,so I made a small change.

```julia
...
....
# Graph Stein discrepancy bounded test
function gsdbt()
    res = gsd(points=UNIFORM_TESTDATA[:,1],
              gradlogdensity=uniform_gradlogp,
              solver=solver,
              supportlowerbounds=[0.0],
              supportupperbounds=[1.0])
end

```

At this point it still runs successfully, including the debug mode.

but my purpose is to step into the gsd function(which defined in src/discrepancy/stein\_discrepancy.jl)  
so i set the breakpoint and `Juno.@enter gsdbt()` in repl. Then i press “next expression” button until the moment i think can enter this function(as shown below), and i press “step into the function”.The error came out like below.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/5/05cc005c4358f5024f599cd05ea4adf6c0033768.png)

```julia
julia> Juno.@enter gsdbt()
ERROR: UndefRefError: access to undefined reference
Stacktrace:
 [1] startdebugging(::Array{ASTInterpreter2.JuliaStackFrame,1}) at /home/nick/.julia/v0.6/Atom/src/debugger/stepper.jl:104
 [2] macro expansion at /home/nick/.julia/v0.6/Atom/src/repl.jl:118 [inlined]
 [3] anonymous at ./<missing>:?
 [4] eval(::Module, ::Any) at ./boot.jl:235
 [5] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [6] macro expansion at ./REPL.jl:97 [inlined]
 [7] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73

```

**I want to step into the gsd function, but i got UndefRefError.  
How can I solve it? Thank you very much.**

——————Here are some weird phenomena that may be helpful to you.——————

Also, i try to enter `Juno.@enter gsd()`( not gsdbt ), I am surprised that Atom automatically switches out a file(.julia/v0.6/SteingDiscrepancy/src/disvrepancy), But I put this project on the desktop, that means they are two files (although the content is the same).

Then an expected error occurred.  
`ERROR: Must provide non-empty array of sample points`

If i type `Juno.@enter gsd(……)` in repl, got UndefRefError directly

```julia
julia> Juno.@enter gsd(points=UNIFORM_TESTDATA[:,1],gradlogdensity=uniform_gradlogp,solver=solver,supportlowerbounds=[0.0],supportupperbounds=[1.0])

ERROR: UndefRefError: access to undefined reference
Stacktrace:
 [1] lookup_var(::ASTInterpreter2.JuliaStackFrame, ::SSAValue) at /home/nick/.julia/v0.6/ASTInterpreter2/src/interpret.jl:3
 [2] evaluate_call(::ASTInterpreter2.JuliaStackFrame, ::Expr) at /home/nick/.julia/v0.6/ASTInterpreter2/src/interpret.jl:32
 [3] _step_expr(::ASTInterpreter2.JuliaStackFrame, ::ASTInterpreter2.JuliaProgramCounter) at /home/nick/.julia/v0.6/ASTInterpreter2/src/interpret.jl:87
 [4] next_until!(::ASTInterpreter2.##7#8, ::ASTInterpreter2.JuliaStackFrame, ::ASTInterpreter2.JuliaProgramCounter) at /home/nick/.julia/v0.6/ASTInterpreter2/src/interpret.jl:144
 [5] maybe_step_through_wrapper!(::Array{ASTInterpreter2.JuliaStackFrame,1}) at /home/nick/.julia/v0.6/ASTInterpreter2/src/ASTInterpreter2.jl:429
 [6] macro expansion at /home/nick/.julia/v0.6/Atom/src/repl.jl:118 [inlined]
 [7] anonymous at ./<missing>:?

```
