From e71c423d7ac2bf070c868a91b9d529880065f846 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 19 Jan 2017 19:09:52 -0500 Subject: [PATCH] fix #20121, segfault in subtyping in big vcat operation --- src/subtype.c | 4 +++- test/subtype.jl | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/subtype.c b/src/subtype.c index 72f1b22402115..08ab72a7d8bd3 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -588,7 +588,9 @@ static int subtype_tuple(jl_datatype_t *xd, jl_datatype_t *yd, jl_stenv_t *e, in if (!vvx && yi == (jl_value_t*)jl_any_type) break; // if y ends in `Vararg{Any}` skip checking everything } - if (xi == lastx && yi == lasty && !jl_has_free_typevars(xi) && !jl_has_free_typevars(yi)) { + if (xi == lastx && + ((yi == lasty && !jl_has_free_typevars(xi) && !jl_has_free_typevars(yi)) || + (yi == lasty && !vx && vy && jl_is_leaf_type(xi)))) { // fast path for repeated elements } else if (e->Runions.depth == 0 && e->Lunions.depth == 0 && !jl_has_free_typevars(xi) && !jl_has_free_typevars(yi)) { diff --git a/test/subtype.jl b/test/subtype.jl index 06287f3fbf4db..e65cb6ecad771 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -826,3 +826,6 @@ test_old() test_intersection() test_properties() test_intersection_properties() + +# issue #20121 +@test NTuple{170,Matrix{Int}} <: (Tuple{Vararg{Union{Array{T,1},Array{T,2},Array{T,3}}}} where T)