D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1503 - Type aliases and tuples of template instances
Summary: Type aliases and tuples of template instances
Status: RESOLVED DUPLICATE of issue 3085
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2007-09-14 07:13 UTC by Max Samukha
Modified: 2014-02-17 22:51 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 Max Samukha 2007-09-14 07:13:30 UTC
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 Stewart Gordon 2007-09-15 09:26:31 UTC
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 Max Samukha 2009-10-21 01:27:05 UTC
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 Manuel König 2010-10-11 12:36:17 UTC
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 ***