Interfaces + mixins => problem
Thomas Kuehne
thomas-dloop at kuehne.cn
Mon May 22 13:21:14 PDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Tom S schrieb am 2006-05-02:
> IMHO the following code should either fail to compile or produce a
> meaningful result:
>
> ----
> import std.stdio;
>
>
> interface Foo {
> template FooImpl() {
> void func();
> }
> mixin FooImpl foo;
> }
>
>
> interface Bar {
> template BarImpl() {
> void func();
> }
> mixin BarImpl bar;
> }
>
>
> class Baz : Foo, Bar {
> static template FooImpl() {
> void func() {
> writefln("FooImpl !");
> }
> }
> mixin FooImpl foo;
>
>
> static template BarImpl() {
> void func() {
> writefln("BarImpl !");
> }
> }
> mixin BarImpl bar;
> }
>
>
> void main() {
> Baz b = new Baz;
> Foo f = b;
> Bar r = b;
>
> f.func();
> r.func();
> }
> ----
>
>
> When ran, it prints:
> FooImpl !
> FooImpl !
>
> It would be really great if it outputed:
> FooImpl !
> BarImpl !
>
>
> If that's a problem, id rather it didn't compile at all...
> Thanks :)
Baz should fail to compile:
> If two different mixins are put in the same scope, and each define a
> declaration with the same name, there is an ambiguity error when the
> declaration is referenced.
Added to DStress as
http://dstress.kuehne.cn/nocompile/m/mixin_22_A.d
http://dstress.kuehne.cn/nocompile/m/mixin_22_B.d
http://dstress.kuehne.cn/nocompile/m/mixin_22_C.d
http://dstress.kuehne.cn/nocompile/m/mixin_22_D.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFEcipq3w+/yD4P9tIRAqSHAKCcHnbOPhUIX4QC+KwCyvpAUJnK/gCggTzf
PqwV/tWwmr5KXtwonp2c3To=
=Sas4
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-bugs
mailing list