ERROR: UndefRefError: access to undefined reference

How to eliminate this error
ERROR: UndefRefError: access to undefined reference

a = 280
A = 1:a
for a in A 
         RandDeviation[a] = rand()
     end

It looks that more context is needed to solve this question. I would expect an UndefVarError if RandDeviation were an undefined variable. But if what you get is an UndefRefError is because there is some object there with an undefined field you are trying to access.

What’s typeof(RandDeviation)?

Today I triggered the same error

nested task error: UndefRefError: access to undefined reference
    Stacktrace:
     [1] getindex
       @ .\essentials.jl:917 [inlined]
     [2] pop!(a::Vector{Function})
       @ Base .\array.jl:1584
     [3] (::var"#13#16")()
       @ Main .\REPL[9]:9

when I was doing _ = pop!(a).

It turns out that I forgot the thread safety—having thread 1 do push!(a, _) while thread 2 doing _ = pop!(a). After adding a Reentrantlock the Error disappears.