October 28, 2005
Deewiant (news:dionmt$afm$1@digitaldaemon.com) and
Dennis Luehring (news:djo1km$280i$1@digitaldaemon.com)
pointed out some gaps in the documentation of nested classes.

http://digitalmars.com/d/class.html#nested
# When a non-static nested class is instantiated, the context
# pointer is assigned before the class's constructor is called,
# therefore the constructor has full access to the enclosing
# variables. A non-static nested class can only be instantiated
# when the necessary context pointer information is avaiable.

class Outer{
    class Inner{
        void foo(){
            Inner i = new Inner;
        }
    }
}

void bar(){
    Outer o = new Outer;
    Outer.Inner i = new o.Inner;
}

In both cases the context pointer information seems
to be present but unused by DMD-0.137.

The samples on the documentation page don't classify the foo and bar cases as "Ok" or "Error". In addition the documentation doesn't explicitly state how the necessary context pointer information has to be provided.

I've added both cases to DStress as http://dstress.kuehne.cn/undefined/class_19_A.d http://dstress.kuehne.cn/undefined/class_19_B.d

but I think, it's sensible and in line with other languages like Java to legalize both situations.

Thomas