[Issue 874] Incorrect codegen (?) with tuples, string constants, and AAs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 12 06:17:50 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=874


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au




--- Comment #2 from Don <clugdbug at yahoo.com.au>  2009-08-12 06:17:48 PDT ---
The equivalent code (below) works correctly on D2. This is a D1-only bug.
---------
import std.stdio;
template AA(V, K) {
    V[K] AA(T...)(T args) {
        V[K] ret;
        K key;

        foreach(i, arg; args) {
            static if(!(i & 1))
                key = arg;
            else
                ret[key] = arg;
        }
        return ret;
    }
}
void main()
{
    string[string] array = AA!(string, string)("a", "b"[], "c"[], "d"[]);
    writefln("length = %d\n", array.length);
    foreach(k, v; array)
        writefln("array[%d]=%s", k, v);
}

-- 
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