Skip to content

Commit

Permalink
inference: type bound error due to free typevar in sparam env (#51013)
Browse files Browse the repository at this point in the history
Fix #50709

This issue *appears* fixed on master due to #50432, which simply removed
the error. This fixes the underlying cause, which is that we sometimes
return typevars in the environment from intersection that have free vars
in their bounds. I think it's reasonable to just widen these
aggressively, since we usually cannot do much with these kinds of
unknown static parameters anyway.

(cherry picked from commit a3e2316)
  • Loading branch information
JeffBezanson authored and IanButterworth committed Sep 16, 2023
1 parent 0eff9d8 commit 763ec69
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 @@ -2182,6 +2182,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 @@ -5086,6 +5086,9 @@ let x = Issue50544((1, Issue50544((2.0, 'x'))))
@test only(Base.return_types(h_issue50544, (typeof(x),))) == Type{Issue50544{Tuple{Int,Float64}}}
end

# 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

# override const-prop' return type with the concrete-eval result
# if concrete-eval returns non-inlineable constant
Base.@assume_effects :foldable function continue_const_prop(i, j)
Expand Down

0 comments on commit 763ec69

Please sign in to comment.