[Issue 12883] New: implicit conversion of struct to mutable via alias this

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jun 9 15:32:20 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12883

          Issue ID: 12883
           Summary: implicit conversion of struct to mutable via alias
                    this
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: ASSIGNED
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nilsbossung at googlemail.com
          Reporter: nilsbossung at googlemail.com

---
static struct S
{
    int x;
    void* dummy;
    @property S mutable() const {return S(42);}
    alias mutable this;
}
void main()
{
    const c = S(13);

    S m1 = c;
    assert(m1.x == 42);

    S m2;
    m2 = c;
    assert(m2.x == 42);

    static void f(S s) {assert(s.x == 42);}
    f(c);
}
---

Pull request is on the way.

--


More information about the Digitalmars-d-bugs mailing list