Skip to content

Commit

Permalink
fix a transitivity issue in specificity, from #26915 (#27042)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored May 10, 2018
1 parent fb1c21c commit 5fb465f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,7 @@ static int tuple_morespecific(jl_datatype_t *cdt, jl_datatype_t *pdt, int invari
int cms = type_morespecific_(ce, pe, invariant, env);
int eqv = !cms && eq_msp(ce, pe, env);

if (!cms && !eqv) {
if (!cms && !eqv && !sub_msp(ce, pe, env)) {
/*
A bound vararg tuple can be more specific despite disjoint elements in order to
preserve transitivity. For example in
Expand Down
9 changes: 9 additions & 0 deletions test/specificity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,12 @@ let A = Tuple{Array{T,N}, Vararg{Int,N}} where {T,N},
@test args_morespecific(B, C)
@test args_morespecific(A, C)
end

# transitivity issue found in #26915
let A = Tuple{Vector, AbstractVector},
B = Tuple{AbstractVecOrMat{T}, AbstractVector{T}} where T,
C = Tuple{AbstractVecOrMat{T}, AbstractVecOrMat{T}} where T
@test args_morespecific(A, B)
@test args_morespecific(B, C)
@test args_morespecific(A, C)
end

0 comments on commit 5fb465f

Please sign in to comment.