www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21959] New: 'alias this' takes precedence over static

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

          Issue ID: 21959
           Summary: 'alias this' takes precedence over static opOpAssign
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: maxsamukha gmail.com

struct S {
static:

    alias get this;

    int get() {
        return 0;
    }

    void opAssign(int) {
    }

    void opOpAssign(string op)(int) {
    }
}

void main() {
    int x = S; // pass
    S = 42; // pass
    S *= 42; // fail, should pass
}

Error: `get()` is not an lvalue and cannot be modified

opOpAssign call is resolved correctly if there is no 'static' or 'alias this'.

--
May 23