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.
Regards,
Iain.