I discuss this here because I think this deserves a wider and more visible discussion.
This is pull request 375 by the _very_ good Kenji Hara: https://github.com/D-Programming-Language/dmd/pull/375 It fixes (or tries to fix) several old and new issues with arrays and array literals, including one that has caused me several troubles in real code: http://d.puremagic.com/issues/show_bug.cgi?id=2356 This one related discussion thread: http://d.puremagic.com/issues/show_bug.cgi?id=5290 It seems Pull 375 also turns this program in a compile-time error: int[3] arr = [1, 2]; void main() {} Walter told me that this code used to work as designed, this means it's not a bug. Despite not being a bug, I think accepting that kind of code is a bug-prone anti-feature. There are two little enhancement requests related to this (not currently implemented in Pull 375): Walter wants this code to work because in some uncommon situations he wants to be free to specify less items than the whole array: int[3] arr = [1, 2]; void main() {} The Python Zen says "Explicit is better than implicit.". Being explicit allows Walter to do what he wants, and allows me to avoid the bugs too. So I (and other people) have suggested this syntax for the uncommon situations where you want to specify less items: int[3] arr = [1, 2, ...]; A related enhancement request solves a little problem I have with D array literals: int[$] arr = [10,2,15,15,14,12,3,7,13,5,9,9,7,9,9,9,11,15,1,1,12,5,14]; This avoids me to manually count how many items there are on the right. Keep in mind that if I write this it currently compiles, despite being a BUG: int[24] arr = [10,2,15,15,14,12,3,7,13,5,9,9,7,9,9,9,11,15,1,1,12,5,14]; void main() {} In my opinion a good compiler has to prevent this bug. Bye, bearophile
