On Saturday, December 15, 2012 19:50:34 Iain Buclaw wrote:
> On Saturday, 15 December 2012 at 18:38:29 UTC, H. S. Teoh wrote:
> > With latest git dmd:
> >     auto makeVoldemort(int x) {
> >     
> >             struct Voldemort {
> >             
> >                     @property int value() { return x; }
> >             
> >             }
> >             return Voldemort();
> >     
> >     }
> >     void main() {
> >     
> >             auto v = makeVoldemort();
> >             writeln(v.value);
> >     
> >     }
> > 
> > Compile error:
> >     test.d(3): Error: function test.makeVoldemort.Voldemort.value
> > 
> > cannot access frame of function test.makeVoldemort
> > 
> > Changing 'struct' to 'class' works. Is this deliberate, or is
> > it a bug?
> > It is certainly inconsistent with Walter's article on Voldemort
> > types,
> > which uses structs as examples.
> > 
> > 
> > T
> 
> Pretty certain it's deliberate.  No closure is created for nested
> structs to access it's parent, complying with it's POD behaviour.

static nested structs don't have access to their outer scopes. Non-static 
structs do. This reeks of a bug.

- Jonathan M Davis

Reply via email to