Skip to content

Commit f89921f

Browse files
authored
fix #27361, error adding method using e.g. Tuple{3} (#27404)
1 parent 61c01aa commit f89921f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/subtype.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,8 +2332,10 @@ static int sub_msp(jl_value_t *a, jl_value_t *b, jl_typeenv_t *env)
23322332
{
23332333
JL_GC_PUSH2(&a, &b);
23342334
while (env != NULL) {
2335-
a = jl_type_unionall(env->var, a);
2336-
b = jl_type_unionall(env->var, b);
2335+
if (jl_is_type(a) || jl_is_typevar(a))
2336+
a = jl_type_unionall(env->var, a);
2337+
if (jl_is_type(b) || jl_is_typevar(b))
2338+
b = jl_type_unionall(env->var, b);
23372339
env = env->prev;
23382340
}
23392341
int sub = jl_subtype(a, b);

test/specificity.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,8 @@ let A = Tuple{Vector, AbstractVector},
202202
@test args_morespecific(B, C)
203203
@test args_morespecific(A, C)
204204
end
205+
206+
# issue #27361
207+
f27361(::M) where M <: Tuple{2} = nothing
208+
f27361(::M) where M <: Tuple{3} = nothing
209+
@test length(methods(f27361)) == 2

0 commit comments

Comments
 (0)