import std.stdio;
void main() {
int[] a = [1,1,1,1];
int[] b = [1,1,1,1];
int[] c;
int[2] d;
c[] = a[] - b[]; // works
c.writeln; // []
d[] = a[] - b[]; // works
d.writeln; // [0, 0]
d[] = a[]; // throws!
// object.Error@(0): Array lengths don't match for copy: 4 != 2
}
In the case of subtraction, it assigns only as many elements as the destination has, but for direct assignment, it throws an error. This is clearly inconsistent. An error should be thrown in all cases, instead of silently dropping elements.
Reported by ixid:
http://forum.dlang.org/thread/[email protected]
Comment #1 by robert.schadek — 2024-12-07T13:35:33Z