Thread overview
[Issue 7406] New: tuple foreach doesn't work with mixed tuples
Jan 31, 2012
dawg@dawgfoto.de
Jan 31, 2012
Kenji Hara
Feb 18, 2012
Walter Bright
January 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7406

           Summary: tuple foreach doesn't work with mixed tuples
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: dawg@dawgfoto.de


--- Comment #0 from dawg@dawgfoto.de 2012-01-30 20:58:19 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7406


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-31 06:50:04 PST ---
https://github.com/D-Programming-Language/dmd/pull/667

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7406



--- Comment #2 from github-bugzilla@puremagic.com 2012-02-17 23:29:23 PST ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7406



--- Comment #3 from github-bugzilla@puremagic.com 2012-02-17 23:53:49 PST ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7406


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------