Skip to content

Commit

Permalink
fix #29528, specificity transitivity error in DiffEqBase
Browse files Browse the repository at this point in the history
(cherry picked from commit f034533)
  • Loading branch information
JeffBezanson authored and KristofferC committed Feb 20, 2020
1 parent 3570b71 commit 5c91eac
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 @@ -2510,7 +2510,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 @@ -2558,7 +2559,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 @@ -225,3 +225,10 @@ MathTypes22592{T,C} = Union{AbstractRGB22592{T},AbstractGray22592{T}}
@test !args_morespecific(Tuple{MathTypes22592, MathTypes22592}, Tuple{AbstractGray22592})

@test args_morespecific(Union{Set,Dict,Vector}, Union{Vector,AbstractSet})

# 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 5c91eac

Please sign in to comment.