[Issue 7445] New: Troubles with array assignment syntax

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 5 11:11:59 PST 2012


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 at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2012-02-05 11:11:58 PST ---
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: -------


More information about the Digitalmars-d-bugs mailing list