July 27, 2014 [Issue 13205] New: Analysis improvement of compile-time array slices length | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13205 Issue ID: 13205 Summary: Analysis improvement of compile-time array slices length Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nobody@puremagic.com Reporter: bearophile_hugs@eml.cc 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 -- |
Copyright © 1999-2021 by the D Language Foundation