Bug 7790 – [CTFE] assignment to AA apply ref argument

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-28T22:11:00Z
Last change time
2015-06-09T05:10:37Z
Keywords
CTFE, pull, wrong-code
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2012-03-28T22:11:30Z
struct Symbol { size_t _id; } size_t foo(Symbol[string] tree) { size_t i; foreach(k, ref v; tree) v._id = ++i; // has no effect return tree["a"]._id; } static assert(foo(["a":Symbol(0)]) == 1); -------- The assignment to the ref value field has no effect. Looks like the value literal is copied before calling the foreach body.
Comment #1 by clugdbug — 2012-12-05T23:53:44Z
Comment #2 by github-bugzilla — 2012-12-06T06:28:50Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/93a019d5b10dc0fdc207912d8311a7498bad0e6b Fix issue 7790 [CTFE] assignment to AA apply ref argument 1. IndexExp: Stop copying the AA whenever it is indexed (This was horrific for performance, as well as being wrong). 2. aaApply: If the value is 'ref', create a reference to the value.
Comment #3 by github-bugzilla — 2013-04-18T11:22:58Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c42dcec4f053ffa65feb278d09efb701fabc6fa0 Fix issue 7790 [CTFE] assignment to AA apply ref argument 1. IndexExp: Stop copying the AA whenever it is indexed (This was horrific for performance, as well as being wrong). 2. aaApply: If the value is 'ref', create a reference to the value.
Comment #4 by bugzilla — 2013-04-18T11:32:20Z