Skip to content

Commit 4da0359

Browse files
authored
Fix Vararg methods widening with unused type variable (#48953)
Avoid possible nested `Vararg`. Fix #48950
1 parent 3f7c046 commit 4da0359

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/gf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,7 @@ static jl_value_t *inst_varargp_in_env(jl_value_t *decl, jl_svec_t *sparams)
642642
int T_has_tv = T && jl_has_typevar(T, v);
643643
int N_has_tv = N && jl_has_typevar(N, v); // n.b. JL_VARARG_UNBOUND check means this should be false
644644
assert(!N_has_tv || N == (jl_value_t*)v);
645-
if (T_has_tv)
646-
vm = jl_type_unionall(v, T);
645+
vm = T_has_tv ? jl_type_unionall(v, T) : T;
647646
if (N_has_tv)
648647
N = NULL;
649648
vm = (jl_value_t*)jl_wrap_vararg(vm, N); // this cannot throw for these inputs

test/core.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7973,3 +7973,6 @@ let spec = only(methods(g47476)).specializations
79737973
@test any(mi -> mi !== nothing && Base.isvatuple(mi.specTypes), spec)
79747974
@test all(mi -> mi === nothing || !Base.has_free_typevars(mi.specTypes), spec)
79757975
end
7976+
7977+
f48950(::Union{Int,d}, ::Union{c,Nothing}...) where {c,d} = 1
7978+
@test f48950(1, 1, 1) == 1

0 commit comments

Comments
 (0)