Issue 14900 - 2.068.0 change log example does not compile
Summary: 2.068.0 change log example does not compile
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2015-08-10 14:25 UTC by timon.gehr
Modified: 2015-08-24 11:44 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description timon.gehr 2015-08-10 14:25:53 UTC
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 Kenji Hara 2015-08-10 16:03:51 UTC
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...
Comment 2 Martin Nowak 2015-08-10 16:41:00 UTC
(In reply to Kenji Hara from comment #1)
> After that, I rewrote the example code to current style WITHOUT testing!
> Finally, unworkable example code is shown in changelog...

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

https://github.com/D-Programming-Language/dmd/pull/4876
Comment 5 Kenji Hara 2015-08-10 16:51:08 UTC
(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.
Comment 7 github-bugzilla 2015-08-23 10:10:18 UTC
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e68741604f64b3e0173fd9ffd2125d6c1e4e65ae
fix Issue 14900 - 2.068.0 change log example does not compile

Fix incomplete parser for statement scope declarations.

https://github.com/D-Programming-Language/dmd/commit/4cf5cf76e2399f14d5673439da48cf511546a7b3
Merge pull request #4918 from 9rnsr/fix14889

Issue 14889 & 14900 & [REG2.068.0] 14911 - Reimplement fix for issue 1215
Comment 8 github-bugzilla 2015-08-24 11:44:30 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e68741604f64b3e0173fd9ffd2125d6c1e4e65ae
fix Issue 14900 - 2.068.0 change log example does not compile

https://github.com/D-Programming-Language/dmd/commit/4cf5cf76e2399f14d5673439da48cf511546a7b3
Merge pull request #4918 from 9rnsr/fix14889