Skip to content

Commit c86c059

Browse files
authored
Merge pull request #84 from JuliaDebug/teh/nothunk
Handle expressions that lower to nothing
2 parents 2eac908 + f80d9b9 commit c86c059

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/JuliaInterpreter.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,9 @@ function prepare_thunk(mod::Module, thunk::Expr, recursive=false)
388388
thunk = Meta.lower(mod, Expr(:block, nothing, thunk))
389389
framecode = JuliaFrameCode(mod, thunk.args[1])
390390
else
391-
return prepare_thunk(mod, Meta.lower(mod, thunk), true)
391+
lwr = Meta.lower(mod, thunk)
392+
isa(lwr, Expr) && return prepare_thunk(mod, lwr, true)
393+
return nothing
392394
end
393395
return prepare_locals(framecode, [])
394396
end

test/interpret.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,7 @@ let TT = Union{UInt8, Int8}
270270
pa = pointer(a)
271271
@interpret unsafe_store!(pa, 0x1, 2)
272272
end
273+
274+
# Some expression can appear nontrivial but lower to nothing
275+
@test isa(JuliaInterpreter.prepare_thunk(Main, :(@static if ccall(:jl_get_UNAME, Any, ()) == :NoOS 1+1 end)), Nothing)
276+
@test isa(JuliaInterpreter.prepare_thunk(Main, :(Base.BaseDocs.@kw_str "using")), Nothing)

0 commit comments

Comments
 (0)