Skip to content

Commit 9b7e90d

Browse files
committed
fix #50709, type bound error due to free typevar in inferred ccall ret type
1 parent 3c18223 commit 9b7e90d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,6 +2186,12 @@ function sp_type_rewrap(@nospecialize(T), linfo::MethodInstance, isreturn::Bool)
21862186
T = UnionAll(v, T)
21872187
end
21882188
end
2189+
if has_free_typevars(T)
2190+
fv = ccall(:jl_find_free_typevars, Vector{Any}, (Any,), T)
2191+
for v in fv
2192+
T = UnionAll(v, T)
2193+
end
2194+
end
21892195
else
21902196
T = rewrap_unionall(T, spsig)
21912197
end

test/compiler/inference.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5142,6 +5142,9 @@ h45759(x::Tuple{Any,Vararg}; kwargs...) = x[1] + h45759(x[2:end]; kwargs...)
51425142
h45759(x::Tuple{}; kwargs...) = 0
51435143
@test only(Base.return_types(h45759, Tuple{Tuple{Int,Int,Int,Int,Int,Int,Int}})) == Int
51445144

5145+
# issue #50709
5146+
@test Base.code_typed_by_type(Tuple{Type{Vector{S}} where {T, S<:AbstractVector{T}}, UndefInitializer, Int})[1][2] == Vector{<:AbstractVector{T}} where T
5147+
51455148
@test only(Base.return_types((typeof([[[1]]]),)) do x
51465149
sum(x) do v
51475150
sum(length, v)

0 commit comments

Comments
 (0)