[Issue 3971] Syntax & semantics for array assigns

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 2 00:05:00 PDT 2011


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



--- Comment #17 from Kenji Hara <k.hara.pg at gmail.com> 2011-11-02 00:04:27 PDT ---
With latest dmd (git master):
----
Rhs is an array, is it compilable?
a       / b             a=b     a[]=b   a=b[]   a[]=b[]
int[3u] / int[3u]       true    true    true    true
int[3u] / int[]         true    true    true    true
int[]   / int[3u]       true    true    true    true
int[]   / int[]         true    true    true    true

Rhs is a element, is it compilable?
a                       a=N     a[]=N   a[0..2]=N
int[3u]                 true    true    true
int[]                   false   true    true

Test code:
----
import std.stdio, std.typetuple;
void main()
{
    writeln("Rhs is an array, is it compilable?");
    writeln("a\t/ b\t\ta=b\ta[]=b\ta=b[]\ta[]=b[]");
    foreach (i, Lhs; TypeTuple!(int[3], int[]))
    foreach (j, Rhs; TypeTuple!(int[3], int[]))
    {
        writef("%s\t/ %s  ", Lhs.stringof, Rhs.stringof);
        Lhs a = [0,0,0];
        Rhs b = [1,2,3];
        writef("\t%s", is(typeof({ a   = b;   })));
        writef("\t%s", is(typeof({ a[] = b;   })));
        writef("\t%s", is(typeof({ a   = b[]; })));
        writef("\t%s", is(typeof({ a[] = b[]; })));
        writeln();
    }
    writeln("\nRhs is a element, is it compilable?");
    writeln("a\t\t\ta=N\ta[]=N\ta[0..2]=N");
    foreach (Lhs; TypeTuple!(int[3], int[]))
    {
        writef("%s\t\t", Lhs.stringof);
        Lhs a = [0,0,0];
        writef("\t%s", is(typeof({ a       = 9; })));
        writef("\t%s", is(typeof({ a[]     = 9; })));
        writef("\t%s", is(typeof({ a[0..2] = 9; })));
        writeln();
    }
}

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