Skip to content

Commit

Permalink
Merge pull request #84 from JuliaDebug/teh/nothunk
Browse files Browse the repository at this point in the history
Handle expressions that lower to nothing
  • Loading branch information
timholy authored Feb 28, 2019
2 parents 2eac908 + f80d9b9 commit c86c059
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/JuliaInterpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ function prepare_thunk(mod::Module, thunk::Expr, recursive=false)
thunk = Meta.lower(mod, Expr(:block, nothing, thunk))
framecode = JuliaFrameCode(mod, thunk.args[1])
else
return prepare_thunk(mod, Meta.lower(mod, thunk), true)
lwr = Meta.lower(mod, thunk)
isa(lwr, Expr) && return prepare_thunk(mod, lwr, true)
return nothing
end
return prepare_locals(framecode, [])
end
Expand Down
4 changes: 4 additions & 0 deletions test/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,7 @@ let TT = Union{UInt8, Int8}
pa = pointer(a)
@interpret unsafe_store!(pa, 0x1, 2)
end

# Some expression can appear nontrivial but lower to nothing
@test isa(JuliaInterpreter.prepare_thunk(Main, :(@static if ccall(:jl_get_UNAME, Any, ()) == :NoOS 1+1 end)), Nothing)
@test isa(JuliaInterpreter.prepare_thunk(Main, :(Base.BaseDocs.@kw_str "using")), Nothing)

0 comments on commit c86c059

Please sign in to comment.