Comment #0 by bearophile_hugs — 2014-07-26T10:30:33Z
I suggest to improve a little the compile-time analysis of slice length copies. This code shows a compile-time accepts-invalid and a compile-time rejects-valid enhancement requests:
void foo(int[8]) {}
void main() {
int[100] a;
int[8] b;
const int i = 20;
b[] = a[i .. i + 9]; // OK, detected at compile-time
int j = 20;
b[] = a[j .. j + 9]; // Bad, missed at compile-time
foo(a[j .. j + 8]); // Bad, wrongly detected at compile-time
}
test.d(6,9): Error: mismatched array lengths, 8 and 9
test.d(9,8): Error: function test.foo (int[8] _param_0) is not callable using argument types (int[])
See also Issue 4939
Comment #1 by robert.schadek — 2024-12-13T18:22:51Z