The .outer property
Stewart Gordon
smjg_1998 at yahoo.com
Sun Mar 6 09:28:09 PST 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.
More information about the Digitalmars-d
mailing list