Skip to content

Commit

Permalink
Merge pull request #17180 from JuliaLang/jb/fix17147
Browse files Browse the repository at this point in the history
fix #17147, segfault in expanding Vararg types
  • Loading branch information
JeffBezanson authored Jun 29, 2016
2 parents 3c60d3e + 16b2de1 commit 528a363
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,7 @@ static jl_value_t *inst_tuple_w_(jl_value_t *t, jl_value_t **env, size_t n,
// Instantiate NTuple{3,Int}
// Note this does not instantiate Tuple{Vararg{Int,3}}; that's done in
// jl_apply_tuple_type_v_
if (jl_is_va_tuple(tt) && ntp == 1 && n == 2) {
if (jl_is_va_tuple(tt) && ntp == 1) {
// If this is a Tuple{Vararg{T,N}} with known N, expand it to
// a fixed-length tuple
jl_value_t *T=NULL, *N=NULL;
Expand Down Expand Up @@ -2787,7 +2787,7 @@ jl_datatype_t *jl_fix_vararg_bound(jl_datatype_t *tt, int nfix)
JL_GC_PUSH2(&env[0], &env[1]);
env[0] = jl_tparam1(jl_tparam(tt, ntp-1));
env[1] = jl_box_long(nfix);
jl_datatype_t *ret = (jl_datatype_t*)jl_instantiate_type_with((jl_value_t*)tt, env, 2);
jl_datatype_t *ret = (jl_datatype_t*)jl_instantiate_type_with((jl_value_t*)tt, env, 1);
JL_GC_POP();
return ret;
}
Expand Down
5 changes: 5 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4332,3 +4332,8 @@ end
let g = f16340(1)
@test isa(typeof(g).name.mt.defs.tvars, TypeVar)
end

# issue #17147
f17147(::Tuple) = 1
f17147{N}(::Vararg{Tuple,N}) = 2
@test f17147((), ()) == 2

0 comments on commit 528a363

Please sign in to comment.