Bug 11500 – Bringing mixed-in operators and constructors to the overload set

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-11T13:57:15Z
Last change time
2024-12-13T18:13:53Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Tommi
See also
https://issues.dlang.org/show_bug.cgi?id=19729
Moved to GitHub: dmd#17625 →

Comments

Comment #0 by tommitissari — 2013-11-11T13:57:15Z
We can bring mixed-in methods to the desired overload set, but not operators or constructors. Here's what I mean: mixin template methodMix() { void foo(int n) { } } mixin template operatorMix() { void opBinary(string op)(int n) { } } mixin template ctorMix() { this(int n) { } } struct MethodTest { mixin methodMix mix; alias foo = mix.foo; void foo(string s) { } } struct OperatorTest { mixin operatorMix mix; alias opBinary = mix.opBinary; void opBinary(string op)(string s) { } // [1] } struct CtorTest { mixin ctorMix mix; // If only I could do the following to bring the // mixed-in constructor to the overload set: //alias this = mix.this; this(string s) { } } void main() { MethodTest mt; mt.foo(3); OperatorTest ot; ot + 3; auto ct = CtorTest(3); // [2] } ----------------- 1. Error: template test.OperatorTest.opBinary(string op)(string s) conflicts with alias test.OperatorTest.opBinary 2. Error: constructor test.CtorTest.this (string s) is not callable using argument types (int)
Comment #1 by samjnaa — 2016-01-13T14:10:55Z
Comment #2 by destructionator — 2016-01-23T18:25:37Z
You can alias __ctor = mixin_thing.__ctor; if it appears in the right order...
Comment #3 by robert.schadek — 2024-12-13T18:13:53Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17625 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB