www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - is this a bug? or how to work around : size of type T!(B) is not known

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