typedef, implicit cast, bug or feature?

Thomas Kuehne thomas-dloop at kuehne.cn
Thu Sep 14 00:23:39 PDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Anders Runesson schrieb am 2006-07-16:
> I'm not sure if this is me missing something, or if it's a bug:
>
> ********
> import std.stdio;
>
> class BaseClass {
>         int BaseProp() { return 1; }
> }
>
> typedef BaseClass ClassTypedef;
>
> void testfunc(ClassTypedef t) {    writefln(t.BaseProp());   }
> *************
>
> this gives the compiler message:
>
> test.d(9): this for BaseProp needs to be type BaseClass not type
> ClassTypedef
>
> The docs say that typedefs can be implicitly cast to their underlying
> type, so why can't t be used as a BaseClass reference? Seems like a bug
> to me.
> /Anders

Added to DStress as
http://dstress.kuehne.cn/run/t/typedef_19_A.d
http://dstress.kuehne.cn/run/t/typedef_19_B.d
http://dstress.kuehne.cn/run/t/typedef_19_C.d
http://dstress.kuehne.cn/run/t/typedef_19_D.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFFCQePLK5blCcjpWoRAjOTAJ0Wq+EMvhRz5tVhKPnunjZrJo2hOwCfU2XV
UlT5ZGmQvjqjvI0H1nKWG1Y=
=8LzP
-----END PGP SIGNATURE-----



More information about the Digitalmars-d-bugs mailing list