www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - roll-up of old bugs: access specifiers broken for templates

This one has been reported a lot, but it's in my bug list so I figured 
I'd re-submit it anyway.  It's currently preventing some unit tests from 
running, so it would be nice if it were fixed.

C:\code\d\bugs>type 101_5.d
// This demonstrates an error with access specifiers using
// nested classes.


import std.c.stdio;


template Templ(T)
{
     class TemplA
     {
     private:
     int val;
     }

     class TemplB
     {
     public:
         this()
         {
             TemplA a = new TemplA();
             a.val = 5;
         }
     }
}

class Class(T)
{
     class ClassA
     {
     private:
         int val;
     }

     this()
     {
         ClassA a = new ClassA();
         a.val = 5; // failure is here
     }
}

int main()
{
     Templ!(int).TemplB tb = new Templ!(int).TemplB();
     Class!(int) cb = new Class!(int)();
     return 0;
}
C:\code\d\bugs>dmd 101_5
101_5.d(38): class 101_5.Class!(int).Class.ClassA member val is not 
accessible
101_5.d(45): template instance 101_5.Class!(int) error instantiating
101_5.d(45): Class!(int) is used as a type
101_5.d(45): new can only create structs, dynamic arrays or class 
objects, not v
oid's
101_5.d(45): cannot implicitly convert expression (new Class!(int)) of 
type void
* to 101_5.Class!(int).Class

C:\code\d\bugs>
Jan 24 2006