Bug 13205 – Analysis improvement of compile-time array slices length

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-07-26T10:30:33Z
Last change time
2024-12-13T18:22:51Z
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#18857 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18857 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB