www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24024] New: cannot pass class this to ref class

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

          Issue ID: 24024
           Summary: cannot pass class this to ref class
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

class C
{
    void mem()
    {
        foo(this); // fails
    }
}

void foo(ref C);

void test()
{
    C c;
    foo(c); // passes
}
-----------
test.d(5): Error: function `test.foo(ref C)` is not callable using argument
types `(C)`
test.d(5):        cannot pass rvalue argument `this` of type `test.C` to
parameter `ref C`

--
Jun 30 2023