Skip to content

Commit b2ab59c

Browse files
JeffBezansonmfasi
authored andcommitted
fix JuliaLang#17147, segfault in expanding Vararg types
1 parent c6f6287 commit b2ab59c

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
@@ -4451,3 +4451,8 @@ end
44514451
let g = f16340(1)
44524452
@test isa(typeof(g).name.mt.defs.tvars, TypeVar)
44534453
end
4454+
4455+
# issue #17147
4456+
f17147(::Tuple) = 1
4457+
f17147{N}(::Vararg{Tuple,N}) = 2
4458+
@test f17147((), ()) == 2

0 commit comments

Comments
 (0)