[Issue 12793] New: inout template member function with templated 'this' doesn't properly apply inout

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri May 23 15:45:40 PDT 2014


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

          Issue ID: 12793
           Summary: inout template member function with templated 'this'
                    doesn't properly apply inout
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at yahoo.com

Sample:

struct X(Data)
{
    Data d;
    inout(Data)* foo(this This)() inout // line 4
    {
        return &d;
    }
}


void main()
{
    immutable x = X!double(5.9);
    auto r = x.foo();
}

Result:

inouttest.d(4): Error: inout on return means inout must be on a parameter as
well for immutable inout(double)*()

Clearly, inout is not applying to the function when it should. Removing "(this
This)" fixes the problem

--


More information about the Digitalmars-d-bugs mailing list