[Bug 85] New: Array of classes doesn't function as array of interfaces

Thomas Kuehne thomas-dloop at kuehne.cn
Thu Apr 6 00:23:49 PDT 2006


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

d-bugmail at puremagic.com schrieb am 2006-04-04:
> Testcase below - originally posted as a comment in Bug 65.
>
> Note that while this can be worked around simply by changing the Class[] to
> I[], the code as it is below generates an incorrect program.
>
> ------------------
> interface I {
>         I[] foo();
>         uint x();
> }
>
> class Class : I {
>         I[] foo() {
>                 // changing this to I[] f = new Class[1] fixes the bug
>                 Class[] f = new Class[1];
>                 f[0] = new Class;
>                 return f;
>         }
>
>         uint x() {
>                 return 0;
>         }
> }
>
> void main() {
>         Class c = new Class();
>         assert (c.x == 0);
>         assert (c.foo[0].x == 0);
> }
> ------------------

Added to DStress as
http://dstress.kuehne.cn/run/i/interface_24_A.d
http://dstress.kuehne.cn/run/i/interface_24_B.d
http://dstress.kuehne.cn/run/i/interface_24_C.d
http://dstress.kuehne.cn/run/i/interface_24_D.d

Thomas


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

iD8DBQFENMm33w+/yD4P9tIRAlC3AJ9QVGQPHBKByi84so9CUlefOXz+LwCgw+Bw
GPcAGQaUavOJYIyT6E6JiR8=
=5NI1
-----END PGP SIGNATURE-----



More information about the Digitalmars-d-bugs mailing list