http://d.puremagic.com/issues/show_bug.cgi?id=4860
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 AssignedTo: nob...@puremagic.com ReportedBy: c...@klickverbot.at --- Comment #0 from klickverbot <c...@klickverbot.at> 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 http://www.digitalmars.com/d/2.0/function.html#function-inheritance): --- import std.stdio; class Base { void foo() { } } class Derived : Base { alias Base.foo foo; override void foo() { } } void main() { auto d = new Derived(); void delegate() dg = &d.foo; writefln("dg: (%s, %s)", dg.ptr, dg.funcptr); } --- As long as the alias is present, the delegate created via »&d.foo« 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 »&d.foo« – replacing »void delegate() dg« with »auto dg« produces »cannot infer type from overloaded function symbol &d.foo«. I would also be happy to learn about any workarounds, since this blocks the release of my D SWIG module. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------