mixin template silently `override` without even a warning message!

Adam D Ruppe destructionator at gmail.com
Sun Oct 9 11:51:22 UTC 2022


On Sunday, 9 October 2022 at 07:10:57 UTC, mw wrote:
> template Foo() {
>     void foo() {writeln("F");}
>     void bar() {foo();}  // fixed to Foo.foo()
> }

You can do

void bar() { this.foo(); }

to explicitly call whichever one ended up on the object itself. 
Otherwise mixin templates work like their own unit with their own 
namespace.

> 3) BUT, the compiler should at least issue a warning message, 
> so the programmer is aware of this name clash.

The name "clash" is one of the specific reasons for the mixin 
template, if it warned there it would be annoying...



More information about the Digitalmars-d mailing list