Skip to content

Commit 822b22f

Browse files
JeffBezansonantoine-levitt
authored andcommitted
fix JuliaLang#39948, stack overflow due to free typevar during jl_type_intersection2 (JuliaLang#39959)
1 parent 11c7bd3 commit 822b22f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/gf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,9 @@ static int jl_type_intersection2(jl_value_t *t1, jl_value_t *t2, jl_value_t **is
16001600
return 0;
16011601
if (is_subty)
16021602
return 1;
1603+
// TODO: sometimes type intersection returns types with free variables
1604+
if (jl_has_free_typevars(t1) || jl_has_free_typevars(t2))
1605+
return 1;
16031606
// determine if type-intersection can be convinced to give a better, non-bad answer
16041607
// if the intersection was imprecise, see if we can do better by switching the types
16051608
*isect2 = jl_type_intersection(t2, t1);

test/subtype.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,3 +1894,10 @@ let T = Type{T} where T<:(AbstractArray{I}) where I<:(Base.IteratorsMD.Cartesian
18941894
@test I <: S
18951895
@test_broken I == typeintersect(S, T)
18961896
end
1897+
1898+
# issue #39948
1899+
let A = Tuple{Array{Pair{T, JT} where JT<:Ref{T}, 1} where T, Vector},
1900+
I = typeintersect(A, Tuple{Vararg{Vector{T}}} where T)
1901+
@test_broken I <: A
1902+
@test_broken !Base.has_free_typevars(I)
1903+
end

0 commit comments

Comments
 (0)