Unexpected behavior of @eval on v0.7?

package

#1

I’m working on https://github.com/GiovineItalia/Compose.jl/pull/282 and I ran into a change in how eval behaves on v0.6 to v0.7 and AFAIK the change isn’t documented.

on v0.6

julia> ex = Expr(:import, Symbol("Fontconfig"))
:(import Fontconfig)

julia> @eval $ex
ERROR: ArgumentError: Module Fontconfig not found in current path.
Run `Pkg.add("Fontconfig")` to install the Fontconfig package.
Stacktrace:
 [1] _require(::Symbol) at ./loading.jl:435
 [2] require(::Symbol) at ./loading.jl:405
 [3] eval(::Module, ::Expr) at ./sysimg.jl:23

julia> import Fontconfig
ERROR: ArgumentError: Module Fontconfig not found in current path.
Run `Pkg.add("Fontconfig")` to install the Fontconfig package.
Stacktrace:
 [1] _require(::Symbol) at ./loading.jl:435
 [2] require(::Symbol) at ./loading.jl:405

while on v0.7.0-DEV.4958 (2 day old master)

julia> ex = Expr(:import, Symbol("Fontconfig"))
:(import Fontconfig)

julia> @eval $ex

julia> import Fontconfig
ERROR: ArgumentError: Module Fontconfig not found in current path.
Run `Pkg.add("Fontconfig")` to install the Fontconfig package.
Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:864

Fontconfig isn’t installed in either case. I don’t see why there is a discrepancy between @evaling an import statement and running the actual import statement?


#2

I’m not sure if this a bug at this point, but I’m thinking of posting it on the github issue tracker


#3

Not sure why it doesn’t throw an error, but the syntax is wrong. On v0.7, it should be:

eval(Expr(:import, Expr(:., :Fontconfig)))

Although probably easier and better to just to load the module directly:

local FC = Base.require(@__MODULE__, :Fontconfig)

Or even better, to use Requires.jl to do the work for you at runtime