Summary: Taking delegates to a member function broken if method
                    is also aliased in from a base class
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Mac OS X
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD

--- Comment #0 from klickverbot <> 2010-09-13 07:53:08 PDT 
Consider the following example (the alias directive in there might seem
strange, but is needed if there would be another, non-overridden overload of
foo (see

import std.stdio;

class Base {
  void foo() {

class Derived : Base {
  alias foo;
  override void foo() {

void main() {
  auto d = new Derived();
  void delegate() dg = &;
  writefln("dg: (%s, %s)", dg.ptr, dg.funcptr);

As long as the alias is present, the delegate created via »&« is invalid –
its funcptr part is null (and indeed, trying to call the delegate yields an
access violation). If the alias directive is removed, everything works as
expected, but as explained above, this is not an option.

What may be also relevant is that DMD fails to infer the type for »&« –
replacing »void delegate() dg« with »auto dg« produces »cannot infer type from
overloaded function symbol &«.

I would also be happy to learn about any workarounds, since this blocks the
release of my D SWIG module.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to