Bug 1503 – Type aliases and tuples of template instances

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-09-14T07:13:00Z
Last change time
2014-02-17T22:51:51Z
Keywords
rejects-valid
Assigned to
nobody
Creator
samukha

Comments

Comment #0 by samukha — 2007-09-14T07:13:30Z
May be a duplicate of other tuple bugs. template Foo(T) { alias T Type; } template Foos(A...) { alias A Foos; } alias Foos!(Foo!(int), Foo!(char)) foos; foos[0].Type x = 20; // Fails ----- Error: no identifier for declarator foos[0]; Works if a redundant typeof is added: typeof(foos[0].Type) x = 20;
Comment #1 by smjg — 2007-09-15T09:26:31Z
Please remember to assign keywords to bug reports. To everybody reading this: Please look through issues you've reported and check for missing keywords.
Comment #2 by samukha — 2009-10-21T01:27:05Z
An extra alias can be added to stop the gap: template Foo(T) { alias T Type; } template Foos(A...) { alias A Foos; } alias Foos!(Foo!(int), Foo!(char)) foos; alias foos[0] foo; foo.Type x = 20;
Comment #3 by manuelk89 — 2010-10-11T12:36:17Z
The typeof(foos[0].Type) x = 20; trick doesn't work for me, but aliasing the array index expr works. This is a duplicate of #3085, which means no declaration of the form a[0].t x; is possible because the parser does not accept that syntax, even when t is a type. Your alias trick bypasses that limitation, that's why it works. *** This issue has been marked as a duplicate of issue 3085 ***