Showing with 29 additions and 4 deletions.
  1. +5 −4 src/template.c
  2. +24 −0 test/runnable/template9.d
9 changes: 5 additions & 4 deletions src/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -1927,10 +1927,10 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(
{
// if tuple parameter and
// tuple parameter was not in function parameter list and
// we're one argument short (i.e. no tuple argument)
if (tp &&
// we're one or more arguments short (i.e. no tuple argument)
if (tparam == tp &&
fptupindex == IDX_NOTFOUND &&
ntargs == dedargs->dim - 1)
ntargs <= dedargs->dim - 1)
{
// make tuple argument an empty tuple
oded = (RootObject *)new Tuple();
Expand Down Expand Up @@ -1965,7 +1965,8 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(

/* Bugzilla 7469: Normalize ti->tiargs for the correct mangling of template instance.
*/
if (Tuple *va = isTuple(oded))
Tuple *va = isTuple(oded);
if (va && va->objects.dim)
{
dedargs->setDim(parameters->dim - 1 + va->objects.dim);
for (size_t j = 0; j < va->objects.dim; j++)
Expand Down
24 changes: 24 additions & 0 deletions test/runnable/template9.d
Original file line number Diff line number Diff line change
Expand Up @@ -4485,6 +4485,29 @@ void test14174()
accepter14174b(); // error
}

/******************************************/
// 14836

template a14836x(alias B, C...)
{
int a14836x(D...)() if (D.length == 0) { return 1; }
int a14836x(D...)(D d) if (D.length > 0) { return 2; }
}
template a14836y(alias B, C...)
{
int a14836y(T, D...)(T t) if (D.length == 0) { return 1; }
int a14836y(T, D...)(T t, D d) if (D.length > 0) { return 2; }
}

void test14836()
{
int v;
assert(a14836x!(v)() == 1);
assert(a14836x!(v)(1) == 2);
assert(a14836y!(v)(1) == 1);
assert(a14836y!(v)(1, 2) == 2);
}

/******************************************/
// 14357

Expand Down Expand Up @@ -4707,6 +4730,7 @@ int main()
test13379();
test13484();
test13694();
test14836();
test14735();

printf("Success\n");
Expand Down