[Issue 7790] New: [CTFE] assignment to AA apply ref argument

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 28 22:11:03 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7790

           Summary: [CTFE] assignment to AA apply ref argument
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dawg at dawgfoto.de


--- Comment #0 from dawg at dawgfoto.de 2012-03-28 22:11:30 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list