Skip to content

Commit 4d9d20f

Browse files
committed
Abandon attempts to force frame construction for "trivial" toplevels
1 parent f4d6328 commit 4d9d20f

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/commands.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ end
138138
through_methoddef_or_done!(@nospecialize(recurse), t::Tuple{Module,Expr,Frame}) =
139139
through_methoddef_or_done!(recurse, t[end])
140140
through_methoddef_or_done!(@nospecialize(recurse), modex::Tuple{Module,Expr,Expr}) = Core.eval(modex[1], modex[3])
141+
through_methoddef_or_done!(@nospecialize(recurse), ::Nothing) = nothing
141142
through_methoddef_or_done!(arg) = through_methoddef_or_done!(finish_and_return!, arg)
142143

143144
function changed_line!(expr, line, fls)

src/construct.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,12 @@ function prepare_thunk(mod::Module, thunk::Expr, recursive::Bool=false)
322322
elseif isexpr(thunk, :error) || isexpr(thunk, :incomplete)
323323
error("lowering returned an error, ", thunk)
324324
elseif recursive
325-
thunk = Meta.lower(mod, Expr(:block, nothing, thunk))
325+
thunk = Meta.lower(mod, thunk)
326+
if isa(thunk, Expr)
327+
# If on 2nd attempt to lower it's still an Expr, just evaluate it
328+
Core.eval(mod, thunk)
329+
return nothing
330+
end
326331
framecode = FrameCode(mod, thunk.args[1])
327332
else
328333
lwr = Meta.lower(mod, thunk)

test/toplevel.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ end
1717
@test JuliaInterpreter.is_doc_expr(ex.args[2])
1818
@test !JuliaInterpreter.is_doc_expr(:(1+1))
1919

20-
@test isa(JuliaInterpreter.prepare_thunk(Main, :(export foo)), Frame)
20+
@test JuliaInterpreter.prepare_thunk(Main, :(export foo)) === nothing
21+
@test JuliaInterpreter.prepare_thunk(Base.Threads, :(global Condition)) === nothing
2122

2223
@test !isdefined(Main, :JIInvisible)
2324
JuliaInterpreter.split_expressions(JIVisible, :(module JIInvisible f() = 1 end))

0 commit comments

Comments
 (0)