Comment #0 by matti.niemenmaa+dbugzilla — 2007-11-04T11:51:57Z
void main() {
int[] foo = [1,2,3][];
}
asdf.d(2): semicolon expected, not '['
void main() {
int[] foo = [1,2,3][0..1];
}
asdf.d(2): semicolon expected, not '['
asdf.d(2): found '..' when expecting ','
Comment #1 by aziz.koeksal — 2007-11-04T12:27:52Z
The array literal is parsed as an array initializer (which must be followed by a semicolon.) You can work around this quite easily:
int[] foo = ([1,2,3])[0..1];
Comment #2 by matti.niemenmaa+dbugzilla — 2007-11-05T01:05:42Z
I knew about this workaround, just forgot to mention it. The other, of course, is to do:
int[] foo = [1,2,3];
foo = foo[0..1];
It's still a bug, though.
Comment #3 by matti.niemenmaa+dbugzilla — 2008-09-05T10:07:15Z
Fixed in DMD 1.035, though not marked as such in the changelog.