Bug 1670 – tupleof an aggregate cannot be used as a template tuple argument
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-11-15T08:53:21Z
Last change time
2019-08-12T10:34:49Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Jarrett Billingsley
Comments
Comment #0 by jarrett.billingsley — 2007-11-15T08:53:21Z
struct S
{
int x;
}
class C
{
int x;
}
union U
{
int x;
}
alias Tuple!(S.tupleof) ST;
alias Tuple!(C.tupleof) CT;
alias Tuple!(U.tupleof) UT;
All of those instantiations give the error "Error: tuple is not a valid template value argument". No, but I'd suppose being tuples that they'd be valid _tuple_ arguments, Mr. Compiler!
Comment #1 by michal.minich — 2009-11-16T05:53:24Z
struct Point { int x; int y; }
void main ()
{
Point p;
mixin Foo!(p.x); // works (prints "x" at compile time)
mixin Foo!(Point.x); // works (prints "x" at compile time)
mixin Foo!(p.tupleof[0]); // Error: expression (Point).x is not a valid template value argument (but still prints "(Point).x" at compile time)
mixin Foo!(Point.tupleof[0]); // Error: expression (Point).x is not a valid template value argument (but still prints "(Point).x" at compile time)
}
template Foo (alias a)
{
pragma (msg, a.stringof);
}
Shouldn't p.x and p.tupleof[0] work the same way ?
tested on DMD 2.036
Comment #2 by razvan.nitu1305 — 2019-08-12T10:34:49Z
This issue has been fixed in D2. Closing as WORKSFORME.