Skip to content

Commit

Permalink
fix #50709, type bound error due to free typevar in inferred ccall re…
Browse files Browse the repository at this point in the history
…t type
  • Loading branch information
JeffBezanson committed Aug 23, 2023
1 parent 3c18223 commit 9b7e90d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,12 @@ function sp_type_rewrap(@nospecialize(T), linfo::MethodInstance, isreturn::Bool)
T = UnionAll(v, T)
end
end
if has_free_typevars(T)
fv = ccall(:jl_find_free_typevars, Vector{Any}, (Any,), T)
for v in fv
T = UnionAll(v, T)
end
end
else
T = rewrap_unionall(T, spsig)
end
Expand Down
3 changes: 3 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5142,6 +5142,9 @@ h45759(x::Tuple{Any,Vararg}; kwargs...) = x[1] + h45759(x[2:end]; kwargs...)
h45759(x::Tuple{}; kwargs...) = 0
@test only(Base.return_types(h45759, Tuple{Tuple{Int,Int,Int,Int,Int,Int,Int}})) == Int

# issue #50709
@test Base.code_typed_by_type(Tuple{Type{Vector{S}} where {T, S<:AbstractVector{T}}, UndefInitializer, Int})[1][2] == Vector{<:AbstractVector{T}} where T

@test only(Base.return_types((typeof([[[1]]]),)) do x
sum(x) do v
sum(length, v)
Expand Down

0 comments on commit 9b7e90d

Please sign in to comment.