www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - template alias bug?

reply Johan Granberg <lijat.meREM OVEgmail.com> writes:
Is this a bug or not? I'm rather new to d so I could hav missed somthing.

typedef Alocator!(Object) GObject;
alias Factory!(Module) GModule;

the above code works fine but this code doesent compile

alias Alocator!(Object) GObject;
alias Factory!(Module) GModule;

It is only the typdef that has changed to an alias so I did not expect 
any diference.
/Johan

COMPLETE CODE BELOW AND ATTATCHED
class Module
{
	abstract GObject createObject();
}

class Factory(T):T
{
	override GObject createObject(){}
}

class Object
{
	GModule*gameModule;//most deriverd module
	
}

class Alocator(T):T
{
	//new();
}

typedef Alocator!(Object) GObject;
//if the above typdef is an alias the folowing error aperes
//bug.d(8): function bug.Factory!(Module).Factory.createObject of type 
Alocator() overrides but is not covariant with bug.Module.createObject 
of type Alocator!(Object)()
//bug.d(26): template instance bug.Factory!(Module) error instantiating
alias Factory!(Module) GModule;

int main(char[][]argvs)
{
	GModule mod=new GModule();
	return 0;
}
Jan 03 2006
next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Johan Granberg schrieb am 2006-01-03:
 Is this a bug or not? I'm rather new to d so I could hav missed somthing.

 typedef Alocator!(Object) GObject;
 alias Factory!(Module) GModule;

 the above code works fine but this code doesent compile

 alias Alocator!(Object) GObject;
 alias Factory!(Module) GModule;

 It is only the typdef that has changed to an alias so I did not expect 
 any diference.
 /Johan
 class Module
 {
 	abstract GObject createObject();
 }

 class Factory(T):T
 {
 	override GObject createObject(){}
 }

 class Object
 {
 	GModule*gameModule;//most deriverd module
 	
 }

 class Alocator(T):T
 {
 	//new();
 }

 typedef Alocator!(Object) GObject;
 //if the above typdef is an alias the folowing error aperes
 //bug.d(8): function bug.Factory!(Module).Factory.createObject of type 
 Alocator() overrides but is not covariant with bug.Module.createObject 
 of type Alocator!(Object)()
 //bug.d(26): template instance bug.Factory!(Module) error instantiating
 alias Factory!(Module) GModule;

 int main(char[][]argvs)
 {
 	GModule mod=new GModule();
 	return 0;
 }
Added to DStress as http://dstress.kuehne.cn/run/t/template_class_16_A.d http://dstress.kuehne.cn/run/t/template_class_16_B.d http://dstress.kuehne.cn/run/t/template_class_16_C.d http://dstress.kuehne.cn/run/t/template_class_16_D.d http://dstress.kuehne.cn/run/t/template_class_16_E.d http://dstress.kuehne.cn/run/t/template_class_16_F.d http://dstress.kuehne.cn/run/t/template_class_16_G.d http://dstress.kuehne.cn/run/t/template_class_16_H.d http://dstress.kuehne.cn/run/t/template_class_16_I.d (template_class_16_F.d contains a potential by-pass) Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDvQqt3w+/yD4P9tIRAgeHAJ4xwceKjBLmkBPtl5oGtHZsGsjZfwCcDWqQ oEcsZRFVqgtWJuc/FOTiZBA= =fMLg -----END PGP SIGNATURE-----
Jan 05 2006
prev sibling parent "Walter Bright" <newshound digitalmars.com> writes:
"Johan Granberg" <lijat.meREM OVEgmail.com> wrote in message 
news:dpee4j$m7a$1 digitaldaemon.com...
 Is this a bug or not? I'm rather new to d so I could hav missed somthing.
It's a bug in the compiler, it should diagnose a forward reference to Alocator!(Object).
Jan 10 2006