digitalmars.D.bugs - is this a bug? or how to work around : size of type T!(B) is not known
- bug d.com (37/37) Apr 13 2005 reposting from:
- Ben Hinkle (4/9) Apr 13 2005 private import t;
reposting from: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/21401 A demo to show the problem: $ cat t.d # where the template T is defined -------------------------------------------- module t; class T (X) { X x; } -------------------------------------------- $ cat a.d # where super-class A is defined -------------------------------------------- module a; private import b; class A { BT b; // A has a field of type BT === T!(B) } -------------------------------------------- $ cat b.d # where sub-class B is defined -------------------------------------------- module b; private import t; private import a; class B : A { } alias T!(B) BT; // BT is just an alias -------------------------------------------- $ dmd -c t.d # no problem $ dmd -c a.d # no problem $ dmd -c b.d # doesn't work! b.d:9: size of type T!(B) is not known b.d:9: size of type T!(B) is not known Is this a bug? should D's module system work in this situation? If not, what's the D's way to make it work? suppose in real code, class T/A/B has to be in different source files. (I tried to put them into one file, then it works.)
Apr 13 2005
It looks like a bug to me. I can only get it to compile if I add to a.d something like:module a; private import b;private import t; alias T!(B) BT; // BT is just an aliasclass A { BT b; // A has a field of type BT === T!(B) }
Apr 13 2005