Skip to content

Fix Vararg methods widening with unused type variable. #48953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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