On Sunday, 2 October 2016 at 09:55:26 UTC, Manu wrote:
Can someone explain this to me?

class Test
{
  inout(int) f() inout { return 10; }

  void t()
  {
    f(); // calls fine with mutable 'this'
auto d = &this.f; // error : inout method Test.f is not callable
using a mutable this
    d();
  }
}

That error message seems very unhelpful, and it's not true. Of course an inout method is callable with a mutable 'this'...

I suspect that the problem is the type for the delegate; "inout(int) delegate()" doesn't leave anything for the type system to resolve the
inout with.
I guess the expectation is that this delegate has it's inout-ness
resolved when you capture the delegate:
  is(typeof(&this.f) == int delegate())
Or if 'this' were const:
  is(typeof(&this.f) == const(int) delegate())

But I get this unhelpful error instead.

What's the story here?

That doesn't compile for me (using ad4a81b), but I get a different error message with an accompanying main
void main()
{
        const ct = new Test();
    ct.t();
    auto at = new Test();
    at.t();
    immutable it = new Test();
    it.t();
}

Error: mutable method Test.t is not callable using a (const|immutable) object
Note t, not f.

Making t inout fixes this.

Reply via email to