www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6523] New: Vector slice assign of a struct with opAssign

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

           Summary: Vector slice assign of a struct with opAssign
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



import std.bigint: BigInt;
void main() {
    BigInt[1] array;
    array[0] = 1;        // OK
    array[] = BigInt(1); // OK
    array[] = 1;         // line 6, error
}



DMD 2.055beta gives:

test.d(6): Error: cannot implicitly convert expression (1) of type int to
BigInt[]


I think this is the reduced version:


struct Foo {
    int x;
    void opAssign(int x) {}
}
void main() {
    Foo[1] array;
    array[0] = 1;     // OK
    array[] = Foo(1); // OK
    array[] = 1;      // error
}


opAssign doesn't get called.

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