Hi
I'm a relatively new Julia user and I've just encountered some issues with
error line reporting; specifically when the short form of function
definition is used, the error refers to the line that called the function
rather than the function itself. My code was as follows
function addexport!(prob::EmbeddedProblem, name::ASCIIString, idx::
AbstractVector)
prob.exports[name] = EmbeddedVar(prob, name, collect(idx), length(idx))
end
addexport!(prob::EmbeddedProblem, name::ASCIIString, idx::Integer) =
addexport(prob, name, [idx]) # Actual problem line; addexport should be
addexport!
function addexports!{T}(prob::EmbeddedProblem, vars::Dict{ASCIIString, T})
for (name, idx) in vars
println("$(name) is $(idx)")
addexport!(prob, name, idx) # Error reported here; line 56
end
end
and I got the error
ERROR: UndefVarError: addexport not defined
in addexports! at /home/db9052/common/research/julia/coco-0.1/Coco.jl:56
I spent quite a while trying to work out why the apparently correct line
was giving an error until I called addexport! directly from the REPL which
then gave me the correct line number. Is this a "feature" or a bug? I guess
that it's something to do with inlining of the function but it confused me
for quite a while...
David