www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14900] New: 2.068.0 change log example does not compile

https://issues.dlang.org/show_bug.cgi?id=14900

          Issue ID: 14900
           Summary: 2.068.0 change log example does not compile
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timon.gehr gmx.ch

Consider the code example at
http://dlang.org/changelog.html#index-type-followed-ident :

---
alias TypeTuple(T...) = T;

struct S
{
    alias T = int;
    alias U = TypeTuple!(long, string);
}

alias Types = Tuple!(S, S);

Types[0].T a;     // Types[0] == S, then typeof(a) == S.T == int
Types[0].U[1] b;  // Types[0].U == S.U, then typeof(b) == S.U[1] == string
---

After fixing the typo:

---
alias TypeTuple(T...)=T;

struct S{
    alias T=int;
    alias U=TypeTuple!(long,string);
}

alias Types=TypeTuple!(S,S);

Types[0].T a;     // Types[0] == S, then typeof(a) == S.T == int
Types[0].U[1] b;  // Types[0].U == S.U, then typeof(b) == S.U[1] == string
---

We get (DMD 2.068.0):

tt.d(10): Error: expected TypeTuple when indexing ('[0]'), got 'Types'.
tt.d(11): Error: expected TypeTuple when indexing ('[0]'), got 'Types'.
tt.d(11): Error: expected TypeTuple when indexing ('[0]'), got 'Types'.

This should compile and do what is indicated.

--
Aug 10 2015