From ea16391c93aeeb10b82684e24b9e063b328023ba Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Wed, 3 Oct 2018 16:12:45 -0400 Subject: [PATCH] fix #29468, bug in intersection of different-length vararg tuples (#29487) --- src/subtype.c | 2 +- test/subtype.jl | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/subtype.c b/src/subtype.c index e4584fb6d0130..ef76c70a8f773 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -1355,7 +1355,7 @@ static jl_value_t *set_var_to_const(jl_varbinding_t *bb, jl_value_t *v JL_MAYBE_ bb->lb = bb->ub = v; } else if (jl_is_long(v) && jl_is_long(bb->lb)) { - if (jl_unbox_long(v) + offset != jl_unbox_long(bb->lb)) + if (jl_unbox_long(v) != jl_unbox_long(bb->lb)) return jl_bottom_type; } else if (!jl_egal(v, bb->lb)) { diff --git a/test/subtype.jl b/test/subtype.jl index 943e8c48d4898..913d9458695be 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -1343,3 +1343,17 @@ struct A28256{names, T<:NamedTuple{names, <:Tuple}} x::T end @test A28256{(:a,), NamedTuple{(:a,),Tuple{Int}}}((a=1,)) isa A28256 + +# issue #29468 +@testintersect(Tuple{Vararg{Val{N}, N}} where N, + Tuple{Val{2}, Vararg{Val{2}}}, + Tuple{Val{2}, Val{2}}) +@testintersect(Tuple{Vararg{Val{N}, N}} where N, + Tuple{Val{3}, Vararg{Val{3}}}, + Tuple{Val{3}, Val{3}, Val{3}}) +@testintersect(Tuple{Vararg{Val{N}, N}} where N, + Tuple{Val{1}, Vararg{Val{2}}}, + Tuple{Val{1}}) +@testintersect(Tuple{Vararg{Val{N}, N}} where N, + Tuple{Val{2}, Vararg{Val{3}}}, + Union{})