Bug 7406 – tuple foreach doesn't work with mixed tuples

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-01-30T20:58:00Z
Last change time
2012-02-18T02:29:11Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2012-01-30T20:58:19Z
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 by k.hara.pg — 2012-01-31T06:50:04Z
Comment #2 by github-bugzilla — 2012-02-17T23:29:23Z
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 by github-bugzilla — 2012-02-17T23:53:49Z