D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7445 - Troubles with array assignment syntax
Summary: Troubles with array assignment syntax
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-05 11:11 UTC by bearophile_hugs
Modified: 2021-01-24 07:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2012-02-05 11:11:58 UTC
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
Comment 1 mhh 2021-01-24 07:06:14 UTC
Combination of language changes (DIP) and things that work/are-invalid now