www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21475] New: template 'this' parameter is incorrectly handled

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

          Issue ID: 21475
           Summary: template 'this' parameter is incorrectly handled for
                    'alias this'
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: maxsamukha gmail.com

struct S {
    string rt;
    void _init(this T)() {
        rt =  T);
    }
}

struct S2 {
    S s;
    alias s this;
}

void main() {
    S2 s2;
    s2._init;
    assert(s2.rt == "S2");
}

T is incorrectly resolved to S, while it should be typeof(s2), which is S2.

--
Dec 12 2020