Skip to content

Commit c0e9182

Browse files
authored
fix UndefVarError for undefined static parameters in statement position (#30886)
1 parent 610880b commit c0e9182

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/compiler/ssair/queries.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function stmt_effect_free(@nospecialize(stmt), @nospecialize(rt), src, spvals::S
1414
if head === :static_parameter
1515
etyp = sparam_type(spvals[e.args[1]])
1616
# if we aren't certain enough about the type, it might be an UndefVarError at runtime
17-
return isa(etyp, Const) || issingletontype(widenconst(etyp))
17+
return isa(etyp, Const)
1818
end
1919
ea = e.args
2020
if head === :call

test/core.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5509,6 +5509,11 @@ f_isdefined_tv(::T) where {T} = @isdefined T
55095509
f_isdefined_va(::T...) where {T} = @isdefined T
55105510
@test !f_isdefined_va()
55115511
@test f_isdefined_va(1, 2, 3)
5512+
function f_unused_undefined_sp(::T...) where T
5513+
T
5514+
return 0
5515+
end
5516+
@test_throws UndefVarError(:T) f_unused_undefined_sp()
55125517

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

0 commit comments

Comments
 (0)