diff --git a/src/gf.c b/src/gf.c index 8861144e92e38..cf22c9b0095a3 100644 --- a/src/gf.c +++ b/src/gf.c @@ -1592,6 +1592,9 @@ static int jl_type_intersection2(jl_value_t *t1, jl_value_t *t2, jl_value_t **is return 0; if (is_subty) return 1; + // TODO: sometimes type intersection returns types with free variables + if (jl_has_free_typevars(t1) || jl_has_free_typevars(t2)) + return 1; // determine if type-intersection can be convinced to give a better, non-bad answer // if the intersection was imprecise, see if we can do better by switching the types *isect2 = jl_type_intersection(t2, t1); diff --git a/test/subtype.jl b/test/subtype.jl index 57d49bc13fa8c..031a1815b2930 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -1878,3 +1878,10 @@ let A = Tuple{Type{<:Union{Number, T}}, Ref{T}} where T, @test A == B @test A <: B end + +# issue #39948 +let A = Tuple{Array{Pair{T, JT} where JT<:Ref{T}, 1} where T, Vector}, + I = typeintersect(A, Tuple{Vararg{Vector{T}}} where T) + @test_broken I <: A + @test_broken !Base.has_free_typevars(I) +end