www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Deprecation still not quite working right

Using DMD 0.97, Windows 98SE.

I see some deprecation bugs have finally been fixed.  But a few remain:

1. Deprecating a class isn't deprecating the class; instead it's 
deprecating each method.  The only difference it makes is that mere 
declarations of the class (whether as a variable, parameter or return 
type) slip through.  Since deprecating all the members is supposed to 
make the class unusable anyway, this is a relatively minor bug, but 
still a bug.

2. Accesses to deprecated member variables are caught only from within 
the class (or a derived class), and only when accessed on the current 
object without "this." or anything to that effect on the beginning.

3. Calls to deprecated constructors or static methods are not caught at 
all from anywhere.

4. The recent fix (unless it's regressed) so that the compiler can 
report more than one error doesn't apply here - DMD is halting on first 
deprecation error, meaning I had to comment out each one in turn to 
discover which cases work.

Below is a testcase.  Each access of a deprecated entity from a 
non-deprecated one is commented to note whether the compiler picks it up.

Stewart.

----------
import std.stdio;

deprecated class DepClass {
     int value;

     this() { value = 42; }

     void print() { writefln(value); }

     static int staticValue;

     static void printSomething() { writefln("Something"); }
}

class ClassWithDeps {
     deprecated int value;

     this() { this(105); }                                   // no

     deprecated this(int v) { value = v; }

     deprecated void print() { writefln(value); }

     deprecated static int staticValue;

     deprecated static void printSomething() { writefln("Something"); }

     static void staticTest() {
         ClassWithDeps obj = new ClassWithDeps;              // no
         obj.value = 666;                                    // no
         obj.print();                                        // yes
         obj.printSomething();                               // no
         obj.staticValue = 101;                              // no
         ClassWithDeps.printSomething();                     // no
         ClassWithDeps.staticValue = 102;                    // no
         printSomething();                                   // no
         staticValue = 103;                                  // no
     }

     void test(ClassWithDeps obj) {
         value = 666;                                        // yes
         print();                                            // yes
         printSomething();                                   // no
         staticValue = 101;                                  // no
         obj.value = 666;                                    // no
         obj.print();                                        // yes
         obj.printSomething();                               // no
         obj.staticValue = 102;                              // no
         this.value = 666;                                   // no
         this.print();                                       // yes
         this.printSomething();                              // no
         this.staticValue = 103;                             // no
         ClassWithDeps.printSomething();                     // no
         ClassWithDeps.staticValue = 104;                    // no
     }
}

void main() {
     DepClass depObject;                                     // no

     depObject = new DepClass;                               // no
     depObject.value = 69;                                   // no
     depObject.print();                                      // yes
     depObject.printSomething();                             // no
     DepClass.printSomething();                              // no

     ClassWithDeps objectWithDeps = new ClassWithDeps(100);  // no
     objectWithDeps.value = 666;                             // no
     objectWithDeps.staticValue = 101;                       // no
     objectWithDeps.print();                                 // yes
     objectWithDeps.printSomething();                        // no
     ClassWithDeps.printSomething();                         // no
     ClassWithDeps.staticValue = 102;
}

DepClass returner(DepClass obj) {                           // no
     return obj;
}

class DerivedClass : ClassWithDeps {
     void printMore() {
         writefln(value);                                    // yes
     }
}

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on 
the 'group where everyone may benefit.
Jul 30 2004