Skip to content

Commit

Permalink
fix bug in setting ninitialized of vararg tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 10, 2017
1 parent 6e72de6 commit 0b2f6de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,9 @@ static jl_value_t *inst_datatype(jl_datatype_t *dt, jl_svec_t *p, jl_value_t **i
JL_GC_PUSH2(&p, &ndt);

jl_value_t *last = iparams[ntp - 1];
int isvatuple = 0;
if (istuple && ntp > 0 && jl_is_vararg_type(last)) {
isvatuple = 1;
// normalize Tuple{..., Vararg{Int, 3}} to Tuple{..., Int, Int, Int}
jl_value_t *va = jl_unwrap_unionall(last);
jl_value_t *va0 = jl_tparam0(va), *va1 = jl_tparam1(va);
Expand Down Expand Up @@ -1185,7 +1187,7 @@ static jl_value_t *inst_datatype(jl_datatype_t *dt, jl_svec_t *p, jl_value_t **i
}
}
if (istuple)
ndt->ninitialized = ntp;
ndt->ninitialized = ntp - isvatuple;
else
ndt->ninitialized = dt->ninitialized;

Expand Down
6 changes: 6 additions & 0 deletions test/tuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,9 @@ end
for n = 0:15
@test ntuple(identity, Val{n}) == ntuple(identity, n)
end

# Tuple type ninitialized
@test Tuple{Int,Any}.ninitialized == 2
@test Tuple.ninitialized == 0
@test Tuple{Int,Vararg{Any}}.ninitialized == 1
@test Tuple{Any,Any,Vararg{Any}}.ninitialized == 2

0 comments on commit 0b2f6de

Please sign in to comment.