Skip to content

Commit 528a363

Browse files
authored
Merge pull request #17180 from JuliaLang/jb/fix17147
fix #17147, segfault in expanding Vararg types
2 parents 3c60d3e + 16b2de1 commit 528a363

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/jltypes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,7 +2341,7 @@ static jl_value_t *inst_tuple_w_(jl_value_t *t, jl_value_t **env, size_t n,
23412341
// Instantiate NTuple{3,Int}
23422342
// Note this does not instantiate Tuple{Vararg{Int,3}}; that's done in
23432343
// jl_apply_tuple_type_v_
2344-
if (jl_is_va_tuple(tt) && ntp == 1 && n == 2) {
2344+
if (jl_is_va_tuple(tt) && ntp == 1) {
23452345
// If this is a Tuple{Vararg{T,N}} with known N, expand it to
23462346
// a fixed-length tuple
23472347
jl_value_t *T=NULL, *N=NULL;
@@ -2787,7 +2787,7 @@ jl_datatype_t *jl_fix_vararg_bound(jl_datatype_t *tt, int nfix)
27872787
JL_GC_PUSH2(&env[0], &env[1]);
27882788
env[0] = jl_tparam1(jl_tparam(tt, ntp-1));
27892789
env[1] = jl_box_long(nfix);
2790-
jl_datatype_t *ret = (jl_datatype_t*)jl_instantiate_type_with((jl_value_t*)tt, env, 2);
2790+
jl_datatype_t *ret = (jl_datatype_t*)jl_instantiate_type_with((jl_value_t*)tt, env, 1);
27912791
JL_GC_POP();
27922792
return ret;
27932793
}

test/core.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4332,3 +4332,8 @@ end
43324332
let g = f16340(1)
43334333
@test isa(typeof(g).name.mt.defs.tvars, TypeVar)
43344334
end
4335+
4336+
# issue #17147
4337+
f17147(::Tuple) = 1
4338+
f17147{N}(::Vararg{Tuple,N}) = 2
4339+
@test f17147((), ()) == 2

0 commit comments

Comments
 (0)