www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14442] New: Wrong this.outer reference in nested classes


          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: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

This is an extension of runnable/nested.d:test35()

class Foo35
   int x = 42;
   void bar()
      int y = 43;
      new class Object
            //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();

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*'

Apr 13 2015