www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7445] New: Troubles with array assignment syntax

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

           Summary: Troubles with array assignment syntax
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This is derived from issue 3971 see there for more (messy) discussions.

Compiling this program:

void main() {
    int[2] a;
    int[2] b[] = a[];
}


Gives with DMD 2.058head:
test.d(3): Error: cannot implicitly convert expression (a[]) of type int[] to
int[2u][]



An alias doesn't solve the problem:

alias double[3] Tri;
void main() {
    Tri a = [1, 2, 3];
    Tri b = [10, 20, 30];
    Tri c[] = a[] - b[];
}


test.d(5): Error: cannot implicitly convert expression (a[] - b[]) of type
double[] to double[3u][]


auto with [] doesn't help:

void main() {
    int[] a = new int[3];
    int[] b = new int[3];
    auto c[] = a[] + b[];
}


test.d(4): no identifier for declarator c[]



auto without [] doesn't help:

void main() {
    int[] a = new int[3];
    int[] b = new int[3];
    auto c = a[] + b[];
}


test.d(4): Error: Array operation a[] + b[] not implemented

(Also note the wrong error message, now the + array op is implemented in DMD.)


See also issue 4580

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 05 2012