Skip to content

Commit

Permalink
fix #22164, specificity issue in ForwardDiff
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 5, 2017
1 parent 4634a3d commit e92eb58
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -2576,10 +2576,9 @@ static int type_morespecific_(jl_value_t *a, jl_value_t *b, int invariant, jl_ty
if (!jl_is_type(b))
return 0;
if (invariant) {
if (num_occurs((jl_tvar_t*)a, env) < 2)
return 0;
if (eq_msp(((jl_tvar_t*)a)->ub, b, env))
return 1;
return num_occurs((jl_tvar_t*)a, env) >= 2;
return 0;
}
return type_morespecific_((jl_value_t*)((jl_tvar_t*)a)->ub, b, 0, env);
}
Expand Down
9 changes: 9 additions & 0 deletions test/specificity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,12 @@ f17016(f, t1::Tuple) = 1

@test args_morespecific(Tuple{Type{CartesianIndex{N}}} where N,
Tuple{Type{CartesianIndex{N}},Vararg{Int,N}} where N)

# issue #22164
let A = Tuple{Type{D},D} where D<:Pair,
B = Tuple{Type{Any}, Any},
C = Tuple{Type{Pair}, Pair}
@test args_morespecific(C, A)
@test !args_morespecific(A, B)
@test !args_morespecific(C, B)
end

0 comments on commit e92eb58

Please sign in to comment.