www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22601] New: Slice assignment not working for compatible types

https://issues.dlang.org/show_bug.cgi?id=22601

          Issue ID: 22601
           Summary: Slice assignment not working for compatible types
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: rumbu rumbu.ro

struct A 
{ 
    int x;    
    void opAssign(B b)
    {
        this.x = b.y;
    }
}
struct B { int y; }

A[] bufa;
B[] bufb;

bufa[0] = bufb[0];
//this works calling bufa[0].opAssign(bufb[0])

bufa[] = bufb[];
//cannot implicitly convert expression `bufb[]` of type `B[]` to `A[]`

Since element assignment is possible, it's supposed that slice assignment to be
allowed to.

--
Dec 14 2021