Skip to content

Commit

Permalink
typemap: handle vararg tuple subtyping in jl_typemap_assoc_by_type
Browse files Browse the repository at this point in the history
Fixes a crash while loading ASTInterpreter

(cherry picked from commit 2a8e892)
ref #18191
  • Loading branch information
Jameson Nash authored and tkelman committed Aug 29, 2016
1 parent 8884d9d commit fcd8f2f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/typemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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)
Expand Down

0 comments on commit fcd8f2f

Please sign in to comment.