From 68e4f54cadd26c4ad08b52421c03346890b7e673 Mon Sep 17 00:00:00 2001 From: N5N3 <2642243996@qq.com> Date: Thu, 13 Apr 2023 21:38:43 +0800 Subject: [PATCH] Fix union estimation on non-type parameters. --- src/subtype.c | 2 +- test/subtype.jl | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/subtype.c b/src/subtype.c index f67e37ee079fc..3f87197356f29 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -1536,7 +1536,7 @@ static int may_contain_union_decision(jl_value_t *x, jl_stenv_t *e, jl_typeenv_t return 0; } if (!jl_is_typevar(x)) - return 1; + return jl_is_type(x); jl_typeenv_t *t = log; while (t != NULL) { if (x == (jl_value_t *)t->var) diff --git a/test/subtype.jl b/test/subtype.jl index 2ec2a8d89e5e0..722f3535168e2 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -2453,8 +2453,11 @@ let A = Tuple{Type{T}, T} where T, @testintersect(A, B, C) end -let a = (isodd(i) ? Pair{Char, String} : Pair{String, String} for i in 1:2000) +let + a = (isodd(i) ? Pair{Char, String} : Pair{String, String} for i in 1:2000) @test Tuple{Type{Pair{Union{Char, String}, String}}, a...} <: Tuple{Type{Pair{K, V}}, Vararg{Pair{A, B} where B where A}} where V where K + a = (isodd(i) ? Matrix{Int} : Vector{Int} for i in 1:4000) + @test Tuple{Type{Pair{Union{Char, String}, String}}, a...,} <: Tuple{Type{Pair{K, V}}, Vararg{Array}} where V where K end #issue 48582