Skip to content

Commit 763ec69

Browse files
JeffBezansonIanButterworth
authored andcommitted
inference: type bound error due to free typevar in sparam env (#51013)
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)
1 parent 0eff9d8 commit 763ec69

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
@@ -2182,6 +2182,12 @@ function sp_type_rewrap(@nospecialize(T), linfo::MethodInstance, isreturn::Bool)
21822182
T = UnionAll(v, T)
21832183
end
21842184
end
2185+
if has_free_typevars(T)
2186+
fv = ccall(:jl_find_free_typevars, Vector{Any}, (Any,), T)
2187+
for v in fv
2188+
T = UnionAll(v, T)
2189+
end
2190+
end
21852191
else
21862192
T = rewrap_unionall(T, spsig)
21872193
end

test/compiler/inference.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5086,6 +5086,9 @@ let x = Issue50544((1, Issue50544((2.0, 'x'))))
50865086
@test only(Base.return_types(h_issue50544, (typeof(x),))) == Type{Issue50544{Tuple{Int,Float64}}}
50875087
end
50885088

5089+
# issue #50709
5090+
@test Base.code_typed_by_type(Tuple{Type{Vector{S}} where {T, S<:AbstractVector{T}}, UndefInitializer, Int})[1][2] == Vector{<:AbstractVector{T}} where T
5091+
50895092
# override const-prop' return type with the concrete-eval result
50905093
# if concrete-eval returns non-inlineable constant
50915094
Base.@assume_effects :foldable function continue_const_prop(i, j)

0 commit comments

Comments
 (0)