Is this actually supposed to be legal?

Jonathan M Davis jmdavisProg at gmx.com
Mon Jul 16 22:24:03 PDT 2012


This code strikes me as being a bug:

--------
class MyBase(T)
{}

class MySubA : MyBase!MySubA
{}

class MySubB : MyBase!MySubB
{}

void main()
{}
--------

but it compiles just fine. However, given the fact that MySubA isn't even 
properly defined until its base class has been defined, I don't see how it could 
possibly _not_ be a bug for the base class to be templatized on it. You could 
get some really weird behavior if you use compile time reflection on the 
derived class in the base class definition.

Does anyone know if this is actually supposed to work? Or is it in fact a bug 
like I think it is?

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list