Skip to content

Commit

Permalink
Fix Vararg methods widening with unused type variable (#48953)
Browse files Browse the repository at this point in the history
Avoid possible nested `Vararg`.

Fix #48950
  • Loading branch information
N5N3 authored Mar 8, 2023
1 parent 3f7c046 commit 4da0359
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,7 @@ static jl_value_t *inst_varargp_in_env(jl_value_t *decl, jl_svec_t *sparams)
int T_has_tv = T && jl_has_typevar(T, v);
int N_has_tv = N && jl_has_typevar(N, v); // n.b. JL_VARARG_UNBOUND check means this should be false
assert(!N_has_tv || N == (jl_value_t*)v);
if (T_has_tv)
vm = jl_type_unionall(v, T);
vm = T_has_tv ? jl_type_unionall(v, T) : T;
if (N_has_tv)
N = NULL;
vm = (jl_value_t*)jl_wrap_vararg(vm, N); // this cannot throw for these inputs
Expand Down
3 changes: 3 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7973,3 +7973,6 @@ let spec = only(methods(g47476)).specializations
@test any(mi -> mi !== nothing && Base.isvatuple(mi.specTypes), spec)
@test all(mi -> mi === nothing || !Base.has_free_typevars(mi.specTypes), spec)
end

f48950(::Union{Int,d}, ::Union{c,Nothing}...) where {c,d} = 1
@test f48950(1, 1, 1) == 1

0 comments on commit 4da0359

Please sign in to comment.