www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12793] New: inout template member function with templated

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 puremagic.com
          Reporter: schveiguy 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

--
May 23 2014