www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16572] New: can't take inout delegate


          Issue ID: 16572
           Summary: can't take inout delegate
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

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

  void t()
    f(); // can call just fine with mutable 'this'
    auto d = &this.f; // error : inout method Test.f is not callable using a
mutable this
    auto e = &this.g; // no problem

Other than the fact that I find this error message terribly misleading, I also
don't think this situation is okay.
It's a terrible edge-case. Are we to say "unlike const, immutable; inout
methods can not be captured as delegates"?

I guess the only reasonable solution here is to 'resolve' the inout-ness at the
delegate capture?

Oct 02 2016