Bug 17055 – this(...) hides this() of mixed in template

Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-01-02T11:58:51Z
Last change time
2020-09-17T21:31:10Z
Assigned to
No Owner
Creator
Ralph Alexander Bariz

Comments

Comment #0 by ralph.bariz — 2017-01-02T11:58:51Z
Expected: Can overload ctors defined inside a mixed in template Observed: When I mixin a template containing this() and define additionally a this(...) I get Error: none of the overloads of '__ctor' are callable using argument types () Notes(ketmar explains why): <RalphBa> can anyone explain me, when I mixin a template containing this() and define additionally a this(...) why I get Error: none of the overloads of '__ctor' are callable using argument types () as soon as I remove the additional this(...) it works :D seems like the additional this(...) would hide the this() from the template well, we are speaking about a class construct would guess I have to alias it, but thats not working with this keyword :D --> BearishMushroom ([email protected]) hat #d betreten * DFeed [GDC] Ma‎rco Le‎ise posted "gdc executable name for install target": http://j.mp/2iZg0EA --> aldacron ([email protected]) hat #d betreten <ketmar> RalphBa: fill a bug <RalphBa> wait, maybe its my fault <ketmar> no <RalphBa> oh :D <ketmar> technically, even mixin template creates a scope that scope is invisible, and should not affect overloads. but it does. <RalphBa> any idea for a temp workaround? <ketmar> only string mixin. alas. you are completely right about bringing overloads in with `alias`, and you are right again about impossibility to do that with ctors ;-)
Comment #1 by b2.temp — 2017-01-15T20:45:48Z
minimal example ?
Comment #2 by ralph.bariz — 2017-01-21T09:42:32Z
////////////////////////////////////////////////////////// mixin template Foo() { int x; this() { this.x=5; } } class Bar { mixin Foo; this(int x) { this.x=x; } } void main() { import std.stdio; auto a = new Bar(); writeln(a.x); } ////////////////////////////////////////////////////////// leads to /d994/f417.d(25): Error: constructor f417.Bar.this (int x) is not callable using argument types ()
Comment #3 by ralph.bariz — 2017-01-21T09:43:54Z
////////////////////////////////////////////////////////// mixin template Foo() { int x; this() { this.x=5; } } class Bar { mixin Foo; } void main() { import std.stdio; auto a = new Bar(); writeln(a.x); } ////////////////////////////////////////////////////////// is building fine
Comment #4 by simen.kjaras — 2020-09-17T21:31:10Z
*** This issue has been marked as a duplicate of issue 3332 ***