digitalmars.D - The .outer property
- Iain Buclaw (21/21) Mar 05 2011 Is this behaviour correct? Should it even be legal to blindly allow acce...
-
Stewart Gordon
(7/23)
Mar 06 2011
-
Stewart Gordon
(5/8)
Mar 06 2011
Is this behaviour correct? Should it even be legal to blindly allow access to members/fields via the .outer context pointer (that may not even be there as shown in this instance)? class Outer { int w = 3; void method() { int x = 4; new class Object { this() { assert(w == 3); // Passes //assert(x == 4); // Passes assert(this.outer.w == 3); // Fails if above is uncommented } }; } } Regards
Mar 05 2011
On 05/03/2011 12:11, Iain Buclaw wrote:Is this behaviour correct? Should it even be legal to blindly allow access to members/fields via the .outer context pointer (that may not even be there as shown in this instance)? class Outer { int w = 3; void method() { int x = 4; new class Object { this() { assert(w == 3); // Passes //assert(x == 4); // Passes assert(this.outer.w == 3); // Fails if above is uncommented<snip> There's clearly a bug at work here. It seems that there's a clash between two context pointers: this and the enclosing function. The compiler should either distinguish between the two or reject the code. I'll investigate. Stewart.
Mar 06 2011
On 05/03/2011 12:11, Iain Buclaw wrote:Is this behaviour correct? Should it even be legal to blindly allow access to members/fields via the .outer context pointer (that may not even be there as shown in this instance)?<snip> Bug filed: http://d.puremagic.com/issues/show_bug.cgi?id=5711 Stewart.
Mar 06 2011