On Friday, 23 May 2014 at 15:14:47 UTC, Chris wrote:
The following:import std.stdio; void main() { int[5] arg;arg[10] = 3; // Compiler says (of course): Error: array index 10 is out of bounds arg[0 .. 5]} import std.stdio; void main() { int[5] arg; foreach (i; 0..10) { arg[i] = i; } }Compiler says nothing, but we get a runtime error 'Range violation'.Bug or design?
The language guarantees catching the out-of-bounds at runtime. The compile-time check is merely a courtesy.