Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions base/compiler/typelimits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,19 @@ function tmeet(@nospecialize(v), @nospecialize(t))
return Bottom
end
@assert widev <: Tuple
new_fields = Vector{Any}(undef, length(v.fields))
if !(ti <: Tuple)
ti = widev
end
new_fields = Vector{Any}(undef, length(ti.parameters))
for i = 1:length(new_fields)
new_fields[i] = tmeet(v.fields[i], widenconst(getfield_tfunc(t, Const(i))))
new_fields[i] = tmeet(getfield_tfunc(v, Const(i)), widenconst(getfield_tfunc(t, Const(i))))
if new_fields[i] === Bottom
return Bottom
end
end
if isvatuple(ti)
new_fields[end] = Vararg{new_fields[end]}
end
return tuple_tfunc(new_fields)
elseif isa(v, Conditional)
if !(Bool <: t)
Expand Down
10 changes: 10 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2980,3 +2980,13 @@ f38888() = S38888(Base.inferencebarrier(3))
@test f38888() isa S38888
g38888() = S38888(Base.inferencebarrier(3), nothing)
@test g38888() isa S38888

# issue #38971
f28971() = (1, [2,3]...)::Tuple{Int,Int,Int}
@test @inferred(f28971()) == (1, 2, 3)
g28971_1() = (1, [2,3]...)::Tuple{Vararg{Int}}
@test @inferred(Tuple{Int, Vararg{Int}}, g28971_1()) == (1, 2, 3)
g28971_2() = (1, [2,3]...)::Tuple{Int, Vararg{Int}}
@test @inferred(Tuple{Int, Vararg{Int}}, g28971_2()) == (1, 2, 3)
g28971_3() = (1, [2,3]...)::Tuple{Int, Int, Vararg{Int}}
@test @inferred(Tuple{Int, Int, Vararg{Int}}, g28971_3()) == (1, 2, 3)