[Issue 1646] New: method overloaded on delegate and function matches both in certain cases

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 7 12:42:00 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1646

           Summary: method overloaded on delegate and function matches both
                    in certain cases
           Product: D
           Version: 2.007
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: schveiguy at yahoo.com


The following code produces the issue:

class A
{
  void f1(void delegate() dg)
  {
  }

  void f1(void function() dg)
  {
  }
}

class C
{
  this()
  {
    A a = new A;
    a.f1(&x);
  }
  void x()
  {
  }
}

The call to f1 should only match the delegate version because x requires a
context pointer.  This was the behavior on D 1.0.

A workaround exists, if you change the line to:

a.f1(&this.x);


-- 



More information about the Digitalmars-d-bugs mailing list