digitalmars.D.bugs - [Issue 1179] New: Compiler doesn't complain about function redefinition when using template mixin
- d-bugmail puremagic.com (25/25) Apr 23 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1179
- d-bugmail puremagic.com (12/12) Apr 23 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1179
- Aarti_pl (13/33) Apr 24 2007 Probably below cite would be more appropriate to describe why my bug was...
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); } --
Apr 23 2007
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. --
Apr 23 2007
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.
Apr 24 2007