September 16, 2012
This doesn't work:
const int[4][4] a = [[10,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]];
int[4][4] b = a.dup;

Error: cannot implicitly convert expression (_adDupT(& D15TypeInfo_xG4G4i6__initZ,cast(const(int[4u])[])a)) of type int[4u][] to int[]

And with dynamic arrays:
Error: cannot implicitly convert expression (_adDupT(& D13TypeInfo_xAAi6__initZ,a)) of type const(int)[][] to int[][]


This does:
const int[4] c = [10,0,0,0];
int[4] d = c.dup;

Shouldn't dup do the former as well and if not how should it be done?
September 16, 2012
On 09/15/2012 09:47 PM, ixid wrote:
> This doesn't work:
> const int[4][4] a = [[10,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]];
> int[4][4] b = a.dup;
>
> Error: cannot implicitly convert expression (_adDupT(&
> D15TypeInfo_xG4G4i6__initZ,cast(const(int[4u])[])a)) of type int[4u][]
> to int[]
>
> And with dynamic arrays:
> Error: cannot implicitly convert expression (_adDupT(&
> D13TypeInfo_xAAi6__initZ,a)) of type const(int)[][] to int[][]
>
>
> This does:
> const int[4] c = [10,0,0,0];
> int[4] d = c.dup;
>
> Shouldn't dup do the former as well and if not how should it be done?

This feels like a limitation to me too. The following workaround works:

    const int[4][4] a = [[10,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]];
    int[4][4] b;
    b = a;

Ali