Skip to content

Commit

Permalink
Check output type of prepare_call more carefully. Fixes #51.
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Feb 21, 2019
1 parent 2f5a96f commit fa4737f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/JuliaInterpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ See [`enter_call`](@ref) for a similar approach not based on expressions.
"""
function enter_call_expr(expr; enter_generated = false)
r = determine_method_for_expr(expr; enter_generated = enter_generated)
if r !== nothing
if isa(r, Tuple)
return build_frame(r[1:end-1]...)
end
nothing
Expand Down Expand Up @@ -841,7 +841,7 @@ function enter_call(@nospecialize(finfo), @nospecialize(args...); kwargs...)
error(f, " is a builtin or intrinsic")
end
r = prepare_call(f, allargs; enter_generated=enter_generated)
if r !== nothing
if isa(r, Tuple)
return build_frame(r[1:end-1]...)
end
return nothing
Expand Down
9 changes: 8 additions & 1 deletion test/interpret.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using JuliaInterpreter
using JuliaInterpreter: enter_call_expr
using Test
using Test, InteractiveUtils

module Isolated end

Expand Down Expand Up @@ -214,3 +214,10 @@ frame = JuliaInterpreter.enter_call(f, 3)
@test JuliaInterpreter.linenumber(frame, JuliaInterpreter.JuliaProgramCounter(1)) == defline + 1
@test JuliaInterpreter.linenumber(frame, JuliaInterpreter.JuliaProgramCounter(3)) == defline + 4
@test JuliaInterpreter.linenumber(frame, JuliaInterpreter.JuliaProgramCounter(5)) == defline + 6

# issue #51
if isdefined(Core.Compiler, :SNCA)
ci = @code_lowered gcd(10, 20)
cfg = Core.Compiler.compute_basic_blocks(ci.code)
@test isa(@interpret(Core.Compiler.SNCA(cfg)), Vector{Int})
end

0 comments on commit fa4737f

Please sign in to comment.