April 14, 2005 is this a bug? or how to work around : size of type T!(B) is not known | ||||
---|---|---|---|---|
| ||||
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.) |
April 14, 2005 Re: is this a bug? or how to work around : size of type T!(B) is not known | ||||
---|---|---|---|---|
| ||||
Posted in reply to bug | 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 alias > > class A { > BT b; // A has a field of type BT === T!(B) > } |
Copyright © 1999-2021 by the D Language Foundation