Bug 5126 – is expression: matched variadic arguments get empty
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-10-27T14:53:00Z
Last change time
2012-06-29T23:33:31Z
Keywords
wrong-code
Assigned to
nobody
Creator
rsinfu
Comments
Comment #0 by rsinfu — 2010-10-27T14:53:08Z
Pattern matching against template variadic arguments was fixed in bug 2725 and now works, but there's still a problem. The matched arguments don't get correctly aliased:
--------------------
struct Test(T...) {}
void main()
{
alias Test!(int, double, string) Test1;
static if (is(Test1 _ : Test!U, U...))
{
static assert(U.length == 3, U.stringof); // (9)
}
}
--------------------
% dmd -o- -c test.d
test.d(9): Error: static assert "()"c
--------------------
It works fine if U is not variadic:
--------------------
struct Test(int n) {}
void main()
{
alias Test!100 Test1;
static if (is(Test1 _ : Test!n, int n))
{
static assert(n == 100); // fine
}
else static assert(0);
}
--------------------