D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6613 - Can't use empty tuple as default value for variadic template function parameter
Summary: Can't use empty tuple as default value for variadic template function parameter
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on: 2803 13950
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-06 12:40 UTC by Vladimir Panteleev
Modified: 2015-06-17 21:04 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2011-09-06 12:40:19 UTC
template Tuple(T...) { alias T Tuple; }

void f(T...)(int arg0 = 0, T argN = Tuple!());

static this() { f(); }

Compiler output:
test.d(3): Error: cannot implicitly convert expression (tuple()) of type () to ()
test.d(5): Error: template instance test.f!() error instantiating

The compiler requires a default value for argN, because it comes after another optional argument, but it doesn't seem like an empty tuple can be specified.
Comment 1 Andrej Mitrovic 2013-02-08 18:01:40 UTC
[internal note]: It seems Tuple!() is treated as a type when it's a default argument (at least ExpInitializer::semantic seems to think so). But as a variable initializer it works ok:

template Tuple(T...) { alias T Tuple; }
void main()
{
    Tuple!() t = Tuple!();
}

CC'ing Kenji since he might be interested in this bug.
Comment 2 Kenji Hara 2015-01-08 03:49:12 UTC
This is one of the case in issue 2803.
And from 2.062, it's also blocked by regression issue 13950.
Comment 4 github-bugzilla 2015-04-18 03:09:16 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/37d633886a342c621ff4705428480f62cc5ab27a
fix Issue 6613 - Can't use empty tuple as default value for variadic template function parameter
Comment 5 github-bugzilla 2015-06-17 21:04:27 UTC
Commit pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/37d633886a342c621ff4705428480f62cc5ab27a
fix Issue 6613 - Can't use empty tuple as default value for variadic template function parameter