Comment #0 by bearophile_hugs — 2010-08-17T07:06:13Z
This D2 program shows two problems (dmd 2.048):
void foo(const double[] arr1) {
arr1[] += 1; // line 2, no error here
double[] arr2;
arr1[] += arr2[]; // line 4, Error here
}
void main() {}
The first problem is at line 2, where the const nature of arr1 is ignored.
The second problem is at line 4, that generates a wrong error message:
test.d(4): Error: invalid array operation arr1[] += cast(const(double[]))arr2[] (did you forget a [] ?)
Comment #1 by yebblies — 2012-01-27T23:27:05Z
*** Issue 7286 has been marked as a duplicate of this issue. ***
Comment #2 by yebblies — 2012-01-27T23:38:19Z
Looks like the fix for issue 5284 only got assignment.
Comment #6 by bearophile_hugs — 2012-07-15T04:15:20Z
The two problems of the example seems fixed. Now this program:
void main() {
const int[] a = new int[5];
int[] b = new int[5];
b[] += a[];
}
Gives:
test.d(4): Error: slice cast(const(int)[])b[] is not mutable
I think is a rejects-valid.
Comment #7 by yebblies — 2012-07-15T06:05:17Z
(In reply to comment #6)
> The two problems of the example seems fixed. Now this program:
>
>
> void main() {
> const int[] a = new int[5];
> int[] b = new int[5];
> b[] += a[];
> }
>
>
> Gives:
> test.d(4): Error: slice cast(const(int)[])b[] is not mutable
>
> I think is a rejects-valid.
Yes, my mistake.
Comment #8 by yebblies — 2012-07-15T06:24:37Z
Ok, not really my mistake, but a problem with typeMerge or the use of typeMerge in BinAssignExp::semantic. It doesn't make any sense for a BinAssignExp or a BinAssignExp::e1 to be type-merged with the rhs, ever.
Bearophile, could you please open another bug for this? It is a regression because this bug previously hid the error.
Comment #9 by bearophile_hugs — 2012-07-15T07:49:23Z
(In reply to comment #8)
> Ok, not really my mistake, but a problem with typeMerge or the use of typeMerge
> in BinAssignExp::semantic. It doesn't make any sense for a BinAssignExp or a
> BinAssignExp::e1 to be type-merged with the rhs, ever.
>
> Bearophile, could you please open another bug for this? It is a regression
> because this bug previously hid the error.
OK, thank you for answering.
I close this bug report as fixed, and I have opened a new regression, Issue 8390