Thread overview |
---|
April 23, 2007 [Issue 1179] New: Compiler doesn't complain about function redefinition when using template mixin | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1179 Summary: Compiler doesn't complain about function redefinition when using template mixin Product: D Version: 1.013 Platform: PC OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: aarti@interia.pl import std.stdio; template t(T) { int policy() { return 1; } } class C { mixin t!(C); int policy() { return 2; } } void main() { writefln((new C).policy); } -- |
April 23, 2007 [Issue 1179] Compiler doesn't complain about function redefinition when using template mixin | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1179 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #1 from bugzilla@digitalmars.com 2007-04-23 14:04 ------- This is the way its supposed to work. Each mixin gets its own namespace, so that names can match names in the non-mixin declarations and other mixin declarations. You can access those conflicting names by using the mixin name as a scope operator. -- |
April 24, 2007 Re: [Issue 1179] Compiler doesn't complain about function redefinition when using template mixin | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | d-bugmail@puremagic.com napisaĆ(a):
> http://d.puremagic.com/issues/show_bug.cgi?id=1179
>
>
> bugzilla@digitalmars.com changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Status|NEW |RESOLVED
> Resolution| |INVALID
>
>
>
>
> ------- Comment #1 from bugzilla@digitalmars.com 2007-04-23 14:04 -------
> This is the way its supposed to work. Each mixin gets its own namespace, so
> that names can match names in the non-mixin declarations and other mixin
> declarations. You can access those conflicting names by using the mixin name as
> a scope operator.
>
>
Probably below cite would be more appropriate to describe why my bug was invalid: :-)) (I don't know any way to access anonymous mixin members - if there is a way to do it I would be happy to know how...)
---
Mixin Scope
The declarations in a mixin are '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.
---
Sorry about invalid bug report. Something strange is happening with mixins in my program, so I thought that it was reason. But it must be something else. I will try to find it out and report in another bug report.
|
Copyright © 1999-2021 by the D Language Foundation