www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21288] New: Wrong context pointer for alias this function

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

          Issue ID: 21288
           Summary: Wrong context pointer for alias this function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: rmanth gmail.com

struct A
{
    int p;
}

struct B
{
    A a() { return A.init; }
    alias a this;
}

struct C
{
    void foo()
    {
        static assert(B.p.stringof == "p"); // Error: this for s needs to be
type B not type C
    }
}

void foo()
{
    static assert(B.p.stringof == "p"); // totally fine
}

--
Oct 01 2020