digitalmars.D.bugs - [Issue 12030] New: Detect some wrong array slice assignments at compile time
- d-bugmail puremagic.com (38/38) Jan 29 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12030
https://d.puremagic.com/issues/show_bug.cgi?id=12030 Summary: Detect some wrong array slice assignments at compile time Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc This contains two related enhancement requests. Some missed compile-time tests: void main() { ubyte[10] a; ubyte[20] b; b[1 .. a.length + 2] = a[]; } With dmd 2.065beta compiles with no errors and then gives at run-time: object.Error: Array lengths don't match for copy: 10 != 11 void main() { int[10] a, b; b[$-5 .. $] = a[0 .. 4]; } With dmd 2.065beta compiles with no errors and then gives at run-time: object.Error: Array lengths don't match for copy: 4 != 5 I'd like those two programs to give compile-time errors. D is a statically typed language, and I think there's there is enough compile-time information to avoid errors at run-time. Second enhancement request: once such tests are done at compile-time, there is NO need to perform them again at run-time, speeding up the code a little. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 29 2014