`artifact_dir` is undefined
Closed this issue · 4 comments
giordano commented
I think there is a problem in the definition of excat
:
julia> using JLLWrappers
julia> JLLWrappers.excat(:(global artifact_dir = find_artifact_dir()))
:($(Expr(:escape, quote
artifact_dir = find_artifact_dir()
end)))
julia> @macroexpand JLLWrappers.@generate_init_header
quote
artifact_dir = find_artifact_dir()
end
the global
disappears and the wrappers don't have the artifact_dir
variable.
CC: @staticfloat
giordano commented
I see
julia> dump(:(global artifact_dir = find_artifact_dir()))
Expr
head: Symbol global
args: Array{Any}((1,))
1: Expr
head: Symbol =
args: Array{Any}((2,))
1: Symbol artifact_dir
2: Expr
head: Symbol call
args: Array{Any}((1,))
1: Symbol find_artifact_dir
but in excat
we're pushing only args
simeonschaub commented
The problem is that the current definition of excat
assumes all its arguments are expressions with head :block
. Try this instead:
# We need to glue expressions together a lot
function excat(exs::Union{Expr,Nothing}...)
ex = Expr(:block)
for exn in exs
exn === nothing && continue
if Meta.isexpr(exn, :block)
append!(ex.args, exn.args)
else
push!(ex.args, exn)
end
end
return esc(ex)
end
giordano commented
@simeonschaub that seems to work great! Would you mind opening a pull request? Don't worry about tests, I'll add them to your pull request 😉
simeonschaub commented
Sure thing: #5