www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12883] New: implicit conversion of struct to mutable via


          Issue ID: 12883
           Summary: implicit conversion of struct to mutable via alias
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: ASSIGNED
          Keywords: rejects-valid
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nilsbossung googlemail.com
          Reporter: nilsbossung 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);}

Pull request is on the way.

Jun 09 2014