May 24, 2006 [Bug 155] New: Nested classes can't return delegates to their parents. | ||||
---|---|---|---|---|
| ||||
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@digitalmars.com ReportedBy: sky@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; } -- |
June 01, 2006 Re: [Bug 155] New: Nested classes can't return delegates to their parents. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail Attachments: | d-bugmail@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 |
Copyright © 1999-2021 by the D Language Foundation