7406 – tuple foreach doesn't work with mixed tuples

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7406 - tuple foreach doesn't work with mixed tuples
Summary: tuple foreach doesn't work with mixed tuples
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2012年01月30日 20:58 UTC by Martin Nowak
Modified: 2012年02月18日 02:29 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Nowak 2012年01月30日 20:58:19 UTC
template TypeTuple(T...)
{
 alias T TypeTuple;
}
template foobar(T)
{
 enum foobar = 2;
}
void main()
{
 foreach(sym; TypeTuple!(int, double)) // OK
 pragma(msg, sym.stringof);
 foreach(sym; TypeTuple!(foobar)) // OK
 pragma(msg, sym.stringof);
 foreach(sym; TypeTuple!(main)) // OK
 pragma(msg, sym.stringof);
 foreach(sym; TypeTuple!(int, foobar)) // Error: type int has no value
 pragma(msg, sym.stringof);
 foreach(sym; TypeTuple!(int, main)) // Error: type int has no value
 pragma(msg, sym.stringof);
}
----
As soon as a symbol is part of the tuple it is treated as expression
tuple. Foreach with an expression tuple then tries to use each tuple
element as initializer which fails for types.
Comment 1 Kenji Hara 2012年01月31日 06:50:04 UTC
https://github.com/D-Programming-Language/dmd/pull/667 
Comment 2 github-bugzilla 2012年02月17日 23:29:23 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd
https://github.com/D-Programming-Language/dmd/commit/992fe402c66b554253ecc8c624a336f6e372e017
Merge pull request #667 from 9rnsr/fix7406
Issue 7406 - tuple foreach doesn't work with mixed tuples
Comment 3 github-bugzilla 2012年02月17日 23:53:49 UTC
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd
https://github.com/D-Programming-Language/dmd/commit/14e3bb9c533c178478c7b8a002b8dc05d58f722f
fix Issue 7406 - tuple foreach doesn't work with mixed tuples


AltStyle によって変換されたページ (->オリジナル) /