This is on Julia 1.10, note that between frame 6 and 7 of the using Plots
stacktrace, there’s no top-level scope
. But between the corresponding frames 1 and 3 in the second example, there is one. Both evaled Exprs are contained by the top-level scope element as demonstrated. We’re using the top-level scope
frame to clean stacktraces of evaled code snippets, and some statements don’t clean well due to this peculiarity which I’m trying to understand.
julia> eval(@show Meta.parseall("using Plots"))
Meta.parseall("using Plots") = :($(Expr(:toplevel, :(#= none:1 =#), :(using Plots))))
ERROR: ArgumentError: Package Plots not found in current path.
- Run `import Pkg; Pkg.add("Plots")` to install the Plots package.
Stacktrace:
[1] macro expansion
@ ./loading.jl:1772 [inlined]
[2] macro expansion
@ ./lock.jl:267 [inlined]
[3] __require(into::Module, mod::Symbol)
@ Base ./loading.jl:1753
[4] #invoke_in_world#3
@ ./essentials.jl:926 [inlined]
[5] invoke_in_world
@ ./essentials.jl:923 [inlined]
[6] require(into::Module, mod::Symbol)
@ Base ./loading.jl:1746
[7] eval
@ ./boot.jl:385 [inlined]
[8] eval(x::Expr)
@ Base.MainInclude ./client.jl:491
[9] top-level scope
@ show.jl:1181
julia> eval(@show Meta.parseall("1 ÷ 0"))
Meta.parseall("1 ÷ 0") = :($(Expr(:toplevel, :(#= none:1 =#), :(1 ÷ 0))))
ERROR: DivideError: integer division error
Stacktrace:
[1] div(x::Int64, y::Int64)
@ Base ./int.jl:295
[2] top-level scope
@ none:1
[3] eval
@ ./boot.jl:385 [inlined]
[4] eval(x::Expr)
@ Base.MainInclude ./client.jl:491
[5] top-level scope
@ show.jl:1181