Hi,
I just found another problem:
import std;
template Foo() {
void foo() {writeln("F");}
void bar() {foo();} // fixed to Foo.foo()
}
class A {
mixin Foo;
void foo() {writeln("A");} // I accidentally added this new name-clashed method
}
void main() {
A a = new A();
a.bar(); // print F
a.foo(); // print A
}
-
class A ends with two methods
foo()
with the same signature! -
whether the foo() in bar() should be fixed to Foo.foo() (non-virtual) is debatable (I can see the reason on both sides).
-
BUT, the compiler should at least issue a warning message, so the programmer is aware of this name clash. Even when a sub-class override a super-class virtual method, the compiler enforces the user to add
override
keyword, but why not in this case?
Has this problem be discussed before? and what's the conclusion?