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

mw mingwu at gmail.com
Sun Oct 9 07:27:54 UTC 2022


On Sunday, 9 October 2022 at 07:24:13 UTC, Mike Parker wrote:
> On Sunday, 9 October 2022 at 07:10:57 UTC, mw wrote:
>
>
>>
>> Has this problem be discussed before? and what's the 
>> conclusion?
>
> This is documented behavior:
>
>> The declarations in a mixin are placed in a nested scope and 
>> then ‘imported’ into the surrounding scope. If the name of a 
>> declaration in a mixin is the same as a declaration in the 
>> surrounding scope, the surrounding declaration overrides the 
>> mixin one:
>
> And then:
>
>> If a mixin has an Identifier, it can be used to disambiguate 
>> between conflicting symbols:
>
> https://dlang.org/spec/template-mixin.html#mixin_scope

OK, it's chosen behavior, that's fine.

BUT, as I said, can the compiler issue a warning message?


More information about the Digitalmars-d mailing list