www.digitalmars.com         C & C++   DMDScript  

D - Bug in template selection

Hi,


    The following code does the unexpected, the second version of the
template is selected when we instance it with Test1. If we change the second
template version to "T : int" instead of plain "T" the code does the right
thing.


template Bug(T : Object) {
    void print() {
        printf("Bug(T : Object).print()\r\n");
    }
}
template Bug(T) {
    void print() {
        printf("Bug(T).print()\r\n");
    }
}
template TTest(T) {
    private instance Bug(T) bug;
    class Test {
        void test() {
            bug.print();
        }
    }
}
int main() {
    alias instance TTest(int).Test Test1;
    alias instance TTest(Test1).Test Test2;
    alias instance TTest(Object).Test Test3;
    Test1 test1 = new Test1();
    Test2 test2 = new Test2();
    Test3 test3 = new Test3();
    test1.test();
    test2.test();
    test3.test();
    return 0;
}


    Best regards,
    Daniel Yokomiso.

"Why aren't you using D by the way? If you like a C-syntax language with
design by contract it seems a perfectly good choice. Why turn Eiffel into D
when D is already there?"
 - Franck Arnaud



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.463 / Virus Database: 262 - Release Date: 17/3/2003
Mar 20 2003