mixin template silently `override` without even a warning message!
mw
mingwu at gmail.com
Sun Oct 9 07:37:27 UTC 2022
On Sunday, 9 October 2022 at 07:27:54 UTC, mw wrote:
> 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?
Especially, this kind of `overrides` is not the same as the class
virtual method override: as I showed in my OP, Foo.bar() is fixed
to call Foo.foo(), no `override` happening; so we are abuse the
concept `override` here.
Let's call it `scope override` to differentiate from `virtual
override`, can the compiler at least issue a warning message?
More information about the Digitalmars-d
mailing list