www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1298] New: More on foreach and tuple

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1298

           Summary: More on foreach and tuple
           Product: D
           Version: 1.017
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: samukha voliacable.com


These may be duplicates of other reported tuple bugs. Also, it would be awesome
if some info about compile-time expansion of foreach on tuples is added to docs
(in ForeachStatement section?). Thanks!

All statements in foreach block below should compile for both CTFE and RTFE:

import std.stdio;

template Foo(Strings...)
{
    char[] bar()
    {
        char[] ret;

        foreach (s; Strings)
        {
            static assert(is(typeof(s) : char[]));  //RTFE ok. CTFE fails
            pragma(msg, typeof(s).stringof);  //RTFE ok. CTFE fails

            pragma(msg, s); //Error: string expected for message, not 's'

            ret ~= s; //RTFE ok. CTFE fails
        }

        return ret;
    }
}

void main(char[][] args)
{
    alias Foo!("eeny", "meeny", "miny", "mo") foo;

    static s = foo.bar();

    writefln(foo.bar());
}


-- 
Jun 29 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1298






One more bug:

template Foo(Strings...)
{
    const a1 = ["one", "two"]; //ok
    const a2 = [Strings]; // Error: cannot implicitly convert expression
(tuple("one","two")) of type (char[3], char[3]) to char
}

void main(char[][] args)
{
    alias Foo!("one", "two") foo;
}


-- 
Jun 29 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1298






The second bug here does not involve CTFE. I've created a new bug (bug

Please don't append new bugs to existing bug reports. It's easy enough to mark
bugs as duplicates, but it's really a pain to split them. Especially once
people have voted for the bug, as in this case.

This one fails because it requires slice assignment to char[] arrays, which is
not yet implemented.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1298


Walter Bright <bugzilla digitalmars.com> changed:

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



22:39:29 PST ---
fixed dmd 1.056 and 2.040

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