From fcd8f2f41bd60a83e819b933b4a305498cf86acb Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 22 Aug 2016 19:57:02 -0400 Subject: [PATCH] typemap: handle vararg tuple subtyping in jl_typemap_assoc_by_type Fixes a crash while loading ASTInterpreter (cherry picked from commit 2a8e892fc14d565db4768e8f8db21e11cbd0c792) ref #18191 --- src/typemap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/typemap.c b/src/typemap.c index 9d308db03d336..b7f959ebf9da4 100644 --- a/src/typemap.c +++ b/src/typemap.c @@ -595,6 +595,7 @@ int sigs_eq(jl_value_t *a, jl_value_t *b, int useenv) static jl_typemap_entry_t *jl_typemap_assoc_by_type_(jl_typemap_entry_t *ml, jl_tupletype_t *types, int8_t inexact, jl_svec_t **penv) { size_t n = jl_field_count(types); + int typesisva = n == 0 ? 0 : jl_is_vararg_type(jl_tparam(types, n-1)); while (ml != (void*)jl_nothing) { size_t lensig = jl_field_count(ml->sig); if (lensig == n || (ml->va && lensig <= n+1)) { @@ -611,10 +612,10 @@ static jl_typemap_entry_t *jl_typemap_assoc_by_type_(jl_typemap_entry_t *ml, jl_ if (ismatch == 0) ; // nothing - else if (ml->isleafsig) + else if (ml->isleafsig && !typesisva) ismatch = sig_match_by_type_leaf(jl_svec_data(types->parameters), ml->sig, lensig); - else if (ml->issimplesig) + else if (ml->issimplesig && !typesisva) ismatch = sig_match_by_type_simple(jl_svec_data(types->parameters), n, ml->sig, lensig, ml->va); else if (ml->tvars == jl_emptysvec)