Skip to content

Commit d55f38a

Browse files
fix Vararg{T,T} where T crashing code_typed (#56081)
Not sure this is the right place to fix this error, perhaps `match.spec_types` should always be a tuple of valid types? fixes #55916 --------- Co-authored-by: Jameson Nash <[email protected]>
1 parent 41b1778 commit d55f38a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ function collect_slot_refinements(𝕃ᵢ::AbstractLattice, applicable::Vector{A
547547
sigt = Bottom
548548
for j = 1:length(applicable)
549549
match = applicable[j]::MethodMatch
550+
valid_as_lattice(match.spec_types, true) || continue
550551
sigt = sigt fieldtype(match.spec_types, i)
551552
end
552553
if sigt argt # i.e. signature type is strictly more specific than the type of the argument slot

test/compiler/inference.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6048,3 +6048,10 @@ t255751 = Array{Float32, 3}
60486048

60496049
issue55882_nfields(x::Union{T,Nothing}) where T<:Number = nfields(x)
60506050
@test Base.infer_return_type(issue55882_nfields) <: Int
6051+
6052+
# issue #55916
6053+
f55916(x) = 1
6054+
f55916(::Vararg{T,T}) where {T} = "2"
6055+
g55916(x) = f55916(x)
6056+
# this shouldn't error
6057+
@test only(code_typed(g55916, (Any,); optimize=false))[2] == Int

0 commit comments

Comments
 (0)