From 95b3f9163027bb95c784fce82e370619a6f8102c Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 4 Dec 2018 14:35:58 -0500 Subject: [PATCH] fix #30122, bad type intersection involving NTuple and Vararg --- src/subtype.c | 4 +++- test/subtype.jl | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/subtype.c b/src/subtype.c index 1504232dbf51e..1121fa9f09575 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -1454,7 +1454,9 @@ static jl_value_t *intersect_var(jl_tvar_t *b, jl_value_t *a, jl_stenv_t *e, int else if (bb->concrete || bb->constraintkind == 1) { jl_value_t *ub = R ? intersect_aside(a, bb->ub, e, d) : intersect_aside(bb->ub, a, e, d); JL_GC_PUSH1(&ub); - if (ub == jl_bottom_type || !subtype_in_env(bb->lb, a, e)) { + if (ub == jl_bottom_type || + // this fixes issue #30122. TODO: better fix for R flag. + (!R && !subtype_in_env(bb->lb, a, e))) { JL_GC_POP(); return jl_bottom_type; } diff --git a/test/subtype.jl b/test/subtype.jl index b5ee66708ce22..aa9ddc7a9ca7a 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -1394,3 +1394,8 @@ let M = M29955{T,Vector{Float64}} where T @test_throws TypeError M{Float32} @test_throws TypeError M{Real} end + +# issue #30122 +@testintersect(Tuple{Pair{Int64,2}, NTuple}, + Tuple{Pair{F,N},Tuple{Vararg{F,N}}} where N where F, + Tuple{Pair{Int64,2}, Tuple{Int64,Int64}})