Bug 6613 – Can't use empty tuple as default value for variadic template function parameter

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-09-06T12:40:00Z
Last change time
2015-06-17T21:04:27Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
dlang-bugzilla
Depends on
2803, 13950

Comments

Comment #0 by dlang-bugzilla — 2011-09-06T12:40:19Z
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 by andrej.mitrovich — 2013-02-08T18:01:40Z
[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 by k.hara.pg — 2015-01-08T03:49:12Z
This is one of the case in issue 2803. And from 2.062, it's also blocked by regression issue 13950.
Comment #3 by k.hara.pg — 2015-01-08T16:19:08Z
Comment #4 by github-bugzilla — 2015-04-18T03:09:16Z
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 by github-bugzilla — 2015-06-17T21:04:27Z
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