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.