[Bug 155] New: Nested classes can't return delegates to their parents.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 24 10:13:17 PDT 2006


http://d.puremagic.com/bugzilla/show_bug.cgi?id=155

           Summary: Nested classes can't return delegates to their parents.
           Product: D
           Version: 0.157
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: sky at quit-clan.de


The following code is expected to print "Hello", but it fails to do so. This
behavior seems independant from any compiler flags.
-------------------------------------------

module nestedclass;

private import std.stdio;

class Foo
{
    class Bar
    {
        void delegate() getDelegate()
        {
            return &sayHello;
        }
    }
    Bar bar;

    void sayHello()
    {
        writefln("Hello");
    }

    this()
    {
        bar = new Bar();
    }
}

int main(char[][] argv)
{
    Foo foo = new Foo();
    void delegate() sayHello = foo.bar.getDelegate();
    writefln("This should print Hello:");
    sayHello();

    return 0;
}


-- 




More information about the Digitalmars-d-bugs mailing list