digitalmars.D.bugs - [Issue 7206] New: Constructor from mixin does not conflict with other constructors
- d-bugmail puremagic.com (41/41) Jan 02 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7206
- d-bugmail puremagic.com (7/7) Jan 02 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7206
- d-bugmail puremagic.com (14/14) Jan 02 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7206
- d-bugmail puremagic.com (20/20) Jan 02 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7206
- d-bugmail puremagic.com (19/19) Apr 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7206
http://d.puremagic.com/issues/show_bug.cgi?id=7206
Summary: Constructor from mixin does not conflict with other
constructors
Product: D
Version: D2
Platform: Other
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: robert octarineparrot.com
22:10:55 GMT ---
----
import std.stdio;
mixin template foo() {
this() {
writefln("a");
}
}
class A {
mixin foo!();
this() {
writefln("b");
}
version(ErrorsAsExpected) {
this() {
writefln("c");
}
}
}
void main() {
A a = new A;
}
----
When the above is compiled, no error is given, however when
-version=ErrorsAsExpected is given an error occurs. Tested with dmd 2.057.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7206 22:13:34 GMT --- I forgot to mention, when ErrorsAsExpected is not defined, this prints b, the constructor from the mixin is disregarded. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 02 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7206
timon.gehr gmx.ch changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |timon.gehr gmx.ch
This is by design:
Spec: 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.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7206
Trass3r <mrmocool gmx.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
CC| |mrmocool gmx.de
Imho it isn't right though to silently accept this.
There should at least be a warning that the code doesn't work as the general
programmer would expect and maybe give a hint that you can achieve overload
resolution with an additional alias.
Otherwise it heavily depends on your code if you are lucky and get an error
message like in http://d.puremagic.com/issues/show_bug.cgi?id=3332 or
unexpected behavior.
This is not limited to constructors. Overload resolution in general isn't
easily possible.
I have to resort to ugly string mixins just because of this.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7206
SomeDude <lovelydear mailmetrash.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lovelydear mailmetrash.com
PDT ---
PS E:\DigitalMars\dmd2\samples> rdmd bug.d
b
PS E:\DigitalMars\dmd2\samples> rdmd -version=ErrorsAsExpected bug.d
bug.d(22): Error: constructor bug.A.this called with argument types:
(())
matches both:
bug.A.this()
and:
bug.A.this()
PS E:\DigitalMars\dmd2\samples>
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 19 2012









d-bugmail puremagic.com 