Bug 10307 – Bad error message for not supported array operation

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-06-08T15:03:00Z
Last change time
2014-12-27T09:17:02Z
Keywords
diagnostic
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-06-08T15:03:11Z
Currently this array operation is not a supported because there is no explicit allocation of the modified array: import std.math; double sum(double[] data) { double result = 0.0; foreach (d; data) result += d; return result; } void main() { double[2] a = [2.0, 3.0]; assert(sum(a[] ^^ 2) == 13.0); } dmd 2.064alpha gives this error message: test.d(10): Error: Array operation a[] ^^ 2L not implemented I suggest to improve the error message.
Comment #1 by k.hara.pg — 2014-07-10T09:36:55Z
With 2.066 the message is improved. test.d(10): Error: array operation a[] ^^ 2L without assignment not implemented
Comment #2 by bearophile_hugs — 2014-07-10T11:10:33Z
(In reply to Kenji Hara from comment #1) > With 2.066 the message is improved. > > test.d(10): Error: array operation a[] ^^ 2L without assignment not > implemented "not implemented" seems to suggest that someday it will implemented. But by design this is not going to happen (unless we decide to change the design of vector ops and allocate the result of a[]^^2 on the stack). So a better error message is: test.d(10): Error: invalid array operation (a[] ^^ 2), no specified memory location for its result
Comment #3 by bearophile_hugs — 2014-12-27T09:17:02Z
Now it prints an acceptable error message: test.d(10,16): Error: array operation a[] ^^ cast(double)2 without destination memory not allowed