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

Thomas Kuehne thomas-dloop at kuehne.cn
Thu Jun 1 10:57:26 PDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail at puremagic.com schrieb am 2006-05-24:
> http://d.puremagic.com/bugzilla/show_bug.cgi?id=155

> 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;
> }

Added to DStress as
http://dstress.kuehne.cn/run/d/delegate_17_A.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFEft6Z3w+/yD4P9tIRAhcTAKDHESG/KoYSou4c8XsP9a8QnJClngCgputO
a1U7irqjK5ys12Q0nSDQiNk=
=obR2
-----END PGP SIGNATURE-----



More information about the Digitalmars-d-bugs mailing list