Skip to content

Commit

Permalink
fix UndefVarError for undefined static parameters in statement positi…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 29, 2019
1 parent 610880b commit c0e9182
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/compiler/ssair/queries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function stmt_effect_free(@nospecialize(stmt), @nospecialize(rt), src, spvals::S
if head === :static_parameter
etyp = sparam_type(spvals[e.args[1]])
# if we aren't certain enough about the type, it might be an UndefVarError at runtime
return isa(etyp, Const) || issingletontype(widenconst(etyp))
return isa(etyp, Const)
end
ea = e.args
if head === :call
Expand Down
5 changes: 5 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5509,6 +5509,11 @@ f_isdefined_tv(::T) where {T} = @isdefined T
f_isdefined_va(::T...) where {T} = @isdefined T
@test !f_isdefined_va()
@test f_isdefined_va(1, 2, 3)
function f_unused_undefined_sp(::T...) where T
T
return 0
end
@test_throws UndefVarError(:T) f_unused_undefined_sp()

# note: the constant `5` here should be > DataType.ninitialized.
# This tests that there's no crash due to accessing Type.body.layout.
Expand Down

0 comments on commit c0e9182

Please sign in to comment.