Bug 10282 – Refused assignment of vector op result to const array

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-06T05:04:00Z
Last change time
2015-06-17T21:05:42Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-06-06T05:04:57Z
struct Foo { double[1] x; } void main() { Foo[] foos; foreach (f; foos) const double[1] a = f.x[] - f.x[]; } DMD 2.064alpha gives a not meaningful error message with no line number: Error: cannot modify const expression p2[p]
Comment #1 by bearophile_hugs — 2014-10-09T11:16:45Z
Now the error message is fixed: test3.d(7,25): Error: invalid array operation 'a[] = f.x[] - f.x[]' for element type const(double) Some more examples: void main() { int[3] a1 = [1, 3, 6]; int[3] a2 = [1, 3, 6] * 3; // OK const int[3] a3 = a1[] * 3; // Error const int[3] a4 = [1, 3, 6] * 3; // Error immutable int[3] a5 = [1, 3, 6] * 3; // Error } dmd 2.067alpha gives: test.d(4,22): Error: _arraySliceExpMulSliceAssign_i (int[] p2, int c1, const(int[]) p0) is not callable using argument types (const(int)[], int, int[]) test.d(5,22): Error: _arraySliceExpMulSliceAssign_i (int[] p2, int c1, const(int[]) p0) is not callable using argument types (const(int)[], int, int[]) test.d(6,22): Error: _arraySliceExpMulSliceAssign_i (int[] p2, int c1, const(int[]) p0) is not callable using argument types (immutable(int)[], int, int[])
Comment #2 by k.hara.pg — 2015-06-04T11:47:21Z
Comment #3 by github-bugzilla — 2015-06-04T21:20:02Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a7ec2c069d9ba6a7b611eba1ce22574647a240f5 fix Issue 10282 - Refused assignment of vector op result to const array https://github.com/D-Programming-Language/dmd/commit/df5a047487f1a2d05859f2c8d9286c3d8b436907 Merge pull request #4718 from 9rnsr/fix10282 Issue 10282 - Refused assignment of vector op result to const array
Comment #4 by github-bugzilla — 2015-06-17T21:05:42Z