Bug 155 – Nested classes can't return delegates to their parents.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-05-24T12:13:00Z
Last change time
2014-02-15T13:19:55Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
sky
Comments
Comment #0 by sky — 2006-05-24T12:13:16Z
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;
}