Skip to content

Commit a409460

Browse files
authored
Merge pull request #161 from JuliaDebug/sp/fix-autoinstall
fix: make sure package autoinstallation works
2 parents 4fc04cc + 90c1683 commit a409460

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/Infiltrator.jl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function __init__()
2828
ccall(:jl_generating_output, Cint, ()) == 0 && clear_store!(store)
2929
INFILTRATION_LOCK[] = ReentrantLock()
3030
if isdefined(Base, :active_repl_backend) && !isnothing(Base.active_repl_backend)
31-
pushfirst!(Base.active_repl_backend.ast_transforms, ast_transformer())
31+
pushfirst!(Base.active_repl_backend.ast_transforms, infiltrator_session_ender)
3232
REPL_HOOKED[] = true
3333
else
3434
atreplinit() do repl
@@ -40,7 +40,7 @@ function __init__()
4040
iter += 1
4141
end
4242
if isdefined(Base, :active_repl_backend)
43-
pushfirst!(Base.active_repl_backend.ast_transforms, ast_transformer())
43+
pushfirst!(Base.active_repl_backend.ast_transforms, infiltrator_session_ender)
4444
REPL_HOOKED[] = true
4545
end
4646
end
@@ -1003,16 +1003,22 @@ let ir_constructs = collect(
10031003
@eval is_ir_construct(@nospecialize x) = typeof(x) in $ir_constructs
10041004
end
10051005

1006-
# runic: off
1007-
function ast_transformer()
1008-
return function (@nospecialize(ex),)
1009-
if ex isa Expr
1010-
return Expr(:try, ex, false, false, :($(@__MODULE__).end_session!()))
1006+
const special_heads = (:meta, :import, :using, :export, :module, :error, :incomplete, :thunk)
1007+
function infiltrator_session_ender(@nospecialize ex)
1008+
if ex isa Expr
1009+
h = ex.head
1010+
if h === :toplevel
1011+
if any(x -> (x isa Expr && x.head in special_heads), ex.args)
1012+
return ex
1013+
end
1014+
elseif h in special_heads
1015+
return ex
10111016
end
1012-
return ex
1017+
1018+
return Expr(:try, ex, false, false, :($(@__MODULE__).end_session!()))
10131019
end
1020+
return ex
10141021
end
1015-
# runic: on
10161022

10171023
# backtraces
10181024

0 commit comments

Comments
 (0)