This code contains two operations that are refused by DMD2.055beta: void main() { int[10] a; a[] += 1; // OK ++a[]; // OK --a[]; // OK a[]++; // line 6, error a[]--; // line 7, error } test2.d(6): Error: slice expression a[] is not a modifiable lvalue test2.d(6): Error: 'a[]' is not a scalar, it is a int[] test2.d(6): Error: cannot cast int to int[] test2.d(7): Error: slice expression a[] is not a modifiable lvalue test2.d(7): Error: 'a[]' is not a scalar, it is a int[] test2.d(7): Error: cannot cast int to int[] Maybe it's better to allow the last two lines too.
This line implies the following a[]++ => (auto tmp = a[].dup, ++a[], tmp) Do we really want it to be this easy to do?
(In reply to comment #1) > This line implies the following > a[]++ => (auto tmp = a[].dup, ++a[], tmp) > > Do we really want it to be this easy to do? I understand. If doing this is not good, then I suggest to turn this into a diagnostic enhancement request. So given code like this: void main() { int[10] a; a[]++; } to raise a single error message that explains why that vector op is on purpose not supported.
(In reply to comment #2) > I understand. If doing this is not good, then I suggest to turn this into a > diagnostic enhancement request. So given code like this: > It's probably not worth introducing yet another hidden allocation, or a special case as it can be easily written using pre-inc. > void main() { > int[10] a; > a[]++; > } > > > to raise a single error message that explains why that vector op is on purpose > not supported. That sounds reasonable, the error message is terrible.
https://github.com/D-Programming-Language/dmd/pull/717
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/176b8752c6f9d92e2570bcb47b87419bf2f0ccd2 Issue 6611 - better error message for array post increment/decrement Detect attempts to use post increment/decrement on an array slice, and print a better error message. https://github.com/D-Programming-Language/dmd/commit/d082916311aca3d14e13295eaafa9b6e52cd81b3 Merge pull request #717 from yebblies/issue6611 Issue 6611 - better error message for array post increment/decrement