Skip to content

Commit

Permalink
fix Vararg{T,T} where T crashing code_typed (JuliaLang#56081)
Browse files Browse the repository at this point in the history
Not sure this is the right place to fix this error, perhaps
`match.spec_types` should always be a tuple of valid types?

fixes JuliaLang#55916

---------

Co-authored-by: Jameson Nash <[email protected]>
  • Loading branch information
simeonschaub and vtjnash authored Oct 11, 2024
1 parent 41b1778 commit d55f38a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ function collect_slot_refinements(𝕃ᵢ::AbstractLattice, applicable::Vector{A
sigt = Bottom
for j = 1:length(applicable)
match = applicable[j]::MethodMatch
valid_as_lattice(match.spec_types, true) || continue
sigt = sigt fieldtype(match.spec_types, i)
end
if sigt argt # i.e. signature type is strictly more specific than the type of the argument slot
Expand Down
7 changes: 7 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6048,3 +6048,10 @@ t255751 = Array{Float32, 3}

issue55882_nfields(x::Union{T,Nothing}) where T<:Number = nfields(x)
@test Base.infer_return_type(issue55882_nfields) <: Int

# issue #55916
f55916(x) = 1
f55916(::Vararg{T,T}) where {T} = "2"
g55916(x) = f55916(x)
# this shouldn't error
@test only(code_typed(g55916, (Any,); optimize=false))[2] == Int

0 comments on commit d55f38a

Please sign in to comment.