www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14672] New: Internal error: e2ir.c 4620 When copying array of

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

          Issue ID: 14672
           Summary: Internal error: e2ir.c 4620 When copying array of
                    derived class to an array of base class
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: petar.p.kirov gmail.com

To reproduce:

class B {}
class D : B {}

void main()
{
    D[] arr_d;
    B[] arr_b;

    arr_b[] = arr_d[]; // Internal error: e2ir.c 4620

    arr_b = cast(B[])arr_d; // Requires cast, cuz of
    arr_b = arr_d; // "Error: cannot implicitly 
                   // convert expression (arr_d) of type D[] to B[]"    

    D d = new D();
    arr_b = [d]; // This does work as expected
}

Tested in DMD64 D Compiler v2.067.1 on Linux.

--
Jun 09 2015