https://issues.dlang.org/show_bug.cgi?id=14442
Issue ID: 14442
Summary: Wrong this.outer reference in nested classes
Product: D
Version: D1 & D2
Hardware: All
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: DMD
Assignee: [email protected]
Reporter: [email protected]
This is an extension of runnable/nested.d:test35()
---
class Foo35
{
int x = 42;
void bar()
{
int y = 43;
new class Object
{
this()
{
//writefln("x = %s", x);
//writefln("y = %s", y);
assert(x == 42);
assert(y == 43);
assert(this.outer.__monitor is null); // <-- nested.d(14):
Assertion failure
}
};
}
}
void test35()
{
Foo35 f = new Foo35();
f.bar();
}
---
The place in marked above will assert at runtime because it's value is '43'.
This tells us that the frontend thinks that the parent chain of the inner class
should be 'Foo35' and not the closure that 'Foo35.bar' creates.
What should happen is that a compiler error be issued.
nested.d(14): Error: no property '__monitor' for type 'void*'
--