Skip to content

Commit

Permalink
fix #29528, specificity transitivity error in DiffEqBase
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Oct 5, 2018
1 parent 50c27fd commit f034533
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,8 @@ static int tuple_morespecific(jl_datatype_t *cdt, jl_datatype_t *pdt, int invari
size_t clen = jl_nparams(cdt);
if (clen == 0) return 1;
int i = 0;
jl_vararg_kind_t ckind = jl_vararg_kind(jl_tparam(cdt,clen-1));
jl_value_t *clast = jl_tparam(cdt,clen-1);
jl_vararg_kind_t ckind = jl_vararg_kind(clast);
int cva = ckind > JL_VARARG_INT;
int pva = jl_vararg_kind(jl_tparam(pdt,plen-1)) > JL_VARARG_INT;
int cdiag = 0, pdiag = 0;
Expand Down Expand Up @@ -2593,7 +2594,7 @@ static int tuple_morespecific(jl_datatype_t *cdt, jl_datatype_t *pdt, int invari
C = Tuple{AbstractArray, Int, Array}
we need A < B < C and A < C.
*/
return some_morespecific && cva && ckind == JL_VARARG_BOUND;
return some_morespecific && cva && ckind == JL_VARARG_BOUND && num_occurs((jl_tvar_t*)jl_tparam1(jl_unwrap_unionall(clast)), env) > 1;
}

// Tuple{..., T} not more specific than Tuple{..., Vararg{S}} if S is diagonal
Expand Down
7 changes: 7 additions & 0 deletions test/specificity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,10 @@ let N = Tuple{Type{Union{Nothing, T}}, Union{Nothing, T}} where T,
@test !args_morespecific(A, N)
@test !args_morespecific(LI, N)
end

# issue #29528
@test !args_morespecific(Tuple{Array,Vararg{Int64,N} where N}, Tuple{AbstractArray, Array})
@test !args_morespecific(Tuple{Array,Vararg{Int64,N}} where N, Tuple{AbstractArray, Array})
@test args_morespecific(Tuple{Array,Int64}, Tuple{Array,Vararg{Int64,N}} where N)
@test args_morespecific(Tuple{Array,Int64}, Tuple{Array,Vararg{Int64,N} where N})
@test !args_morespecific(Tuple{Array,Int64}, Tuple{AbstractArray, Array})

0 comments on commit f034533

Please sign in to comment.