# Missing \`top-level scope\` when \`eval\`ing

**URL:** <https://discourse.julialang.org/t/missing-top-level-scope-when-eval-ing/113728>\
**Category:** General Usage\
**Created:** [May 2, 2024, 10:32am UTC](https://discourse.julialang.org/t/missing-top-level-scope-when-eval-ing/113728 "2024-05-02T10:32:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [May 2, 2024, 10:32am UTC](https://discourse.julialang.org/t/missing-top-level-scope-when-eval-ing/113728/1 "2024-05-02T10:32:27Z")

</div>

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
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

```
