Bug 14900 – 2.068.0 change log example does not compile
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-08-10T14:25:00Z
Last change time
2015-08-24T11:44:30Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
timon.gehr
Comments
Comment #0 by timon.gehr — 2015-08-10T14:25:53Z
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.
Comment #1 by k.hara.pg — 2015-08-10T16:03:51Z
OH MY GOD! The example code does not work even on master!
When I wrote the example code, I did tested it something like.
alias TypeTuple(T...) = T;
struct S
{
alias T = int;
alias U = TypeTuple!(long, string);
}
alias Types = TypeTuple!(S, S);
struct X(Types...) // used tuple parameter
{
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
}
alias x = X!Types;
After that, I rewrote the example code to current style WITHOUT testing! Finally, unworkable example code is shown in changelog...
(In reply to Martin Nowak from comment #2)
> No worries, let's update the changelog then, and apparantly you're already
> working on a fix.
>
> https://github.com/D-Programming-Language/dlang.org/pull/1063
Thank you... I confirmed and merged the fix for the changelog example.