Skip to content

Commit

Permalink
Merge pull request #166 from JuliaDebug/kc/udnef_sparam
Browse files Browse the repository at this point in the history
fix accessing undef sparam
  • Loading branch information
timholy authored Mar 16, 2019
2 parents 3fa687f + 3a71916 commit cecd925
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ end
function lookup_expr(frame, e::Expr)
head = e.head
head == :the_exception && return frame.framedata.last_exception[]
head == :static_parameter && return frame.framedata.sparams[e.args[1]::Int]
if head == :static_parameter
arg = e.args[1]::Int
if isassigned(frame.framedata.sparams, arg)
return frame.framedata.sparams[arg]
else
syms = sparam_syms(frame.framecode.scope)
throw(UndefVarError(syms[arg]))
end
end
head == :boundscheck && length(e.args) == 0 && return true
error("invalid lookup expr ", e)
end
Expand Down
12 changes: 12 additions & 0 deletions test/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,15 @@ file, line = JuliaInterpreter.whereis(fr)
@test isfile(file)
@test isfile(JuliaInterpreter.getfile(fr.framecode.src.linetable[1]))
@test occursin(Sys.STDLIB, repr(fr))

# Test undef sparam (https://github.com/JuliaDebug/JuliaInterpreter.jl/issues/165)
function foo(x::T) where {T <: AbstractString, S <: AbstractString}
return S
end
e = try
@interpret foo("")
catch err
err
end
@test e isa UndefVarError
@test e.var == :S

0 comments on commit cecd925

Please sign in to comment.