Bug 12985 – Better error message for not supported array operation

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-24T21:35:00Z
Last change time
2015-02-18T03:37:53Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-06-24T21:35:22Z
void foo(int[] b) {} void main() { int[2] a = [1, 2]; foo(a[] * 2); } dmd 2.066alpha gives: test.d(4,9): Error: array operation a[] * 2 without assignment not implemented I suggest a better error message like: test.d(4,9): Error: array operations that allocate memory are not supported for performance reasons See also issue 10307
Comment #1 by k.hara.pg — 2014-09-21T16:12:05Z
From https://issues.dlang.org/show_bug.cgi?id=12179#c7 > The error message for the original code is: > > test.d(4,6): Error: array operation a[] * a[] without assignment not > implemented > > But perhaps a better error message is related to this: > > test.d(4,6): Error: array operation a[] * a[] without explicit destination > memory not allowed > > Because I think not allocating memory from array ops is a design decision, > and it will not be implemented. I think "without destination memory not allowed" would be better.
Comment #2 by bearophile_hugs — 2014-09-21T16:43:13Z
(In reply to Kenji Hara from comment #1) > I think "without destination memory not allowed" would be better. I am not a native English speaker, we need one to find the best phrasing :-)
Comment #3 by bearophile_hugs — 2014-09-21T17:59:20Z
Currently this case gets refused, but here the result of the array operation has a memory zone to go (the stack, inside the variable f): struct Foo { int[3] a; } void main() { int[3] b; auto f = Foo(b[] / 2); }
Comment #4 by k.hara.pg — 2014-10-01T16:26:03Z
Comment #5 by github-bugzilla — 2014-10-05T03:20:20Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2ae8fe46c7f7a8a8c464a1d40d306f9f2926ebca fix Issue 12985 - Better error message for not supported array operation https://github.com/D-Programming-Language/dmd/commit/f8265aed59ee1256b52d7d1e360336b2c380b989 Merge pull request #4039 from 9rnsr/fix12985 Issue 12985 - Better error message for not supported array operation
Comment #6 by github-bugzilla — 2015-02-18T03:37:53Z