Skip to content

Commit 8b83fa7

Browse files
committed
fix #22164, specificity issue in ForwardDiff
1 parent 050cbc7 commit 8b83fa7

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/subtype.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,10 +2576,9 @@ static int type_morespecific_(jl_value_t *a, jl_value_t *b, int invariant, jl_ty
25762576
if (!jl_is_type(b))
25772577
return 0;
25782578
if (invariant) {
2579-
if (num_occurs((jl_tvar_t*)a, env) < 2)
2580-
return 0;
25812579
if (eq_msp(((jl_tvar_t*)a)->ub, b, env))
2582-
return 1;
2580+
return num_occurs((jl_tvar_t*)a, env) >= 2;
2581+
return 0;
25832582
}
25842583
return type_morespecific_((jl_value_t*)((jl_tvar_t*)a)->ub, b, 0, env);
25852584
}

test/specificity.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,12 @@ f17016(f, t1::Tuple) = 1
142142

143143
@test args_morespecific(Tuple{Type{CartesianIndex{N}}} where N,
144144
Tuple{Type{CartesianIndex{N}},Vararg{Int,N}} where N)
145+
146+
# issue #22164
147+
let A = Tuple{Type{D},D} where D<:Pair,
148+
B = Tuple{Type{Any}, Any},
149+
C = Tuple{Type{Pair}, Pair}
150+
@test args_morespecific(C, A)
151+
@test !args_morespecific(A, B)
152+
@test !args_morespecific(C, B)
153+
end

0 commit comments

Comments
 (0)