[Issue 7406] New: tuple foreach doesn't work with mixed tuples

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 30 20:58:20 PST 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 at puremagic.com
        ReportedBy: dawg at dawgfoto.de


--- Comment #0 from dawg at 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: -------


More information about the Digitalmars-d-bugs mailing list