digitalmars.D.bugs - [Issue 19365] New: operator overloading set of mixin template is not
- d-bugmail puremagic.com (38/38) Nov 05 2018 https://issues.dlang.org/show_bug.cgi?id=19365
https://issues.dlang.org/show_bug.cgi?id=19365 Issue ID: 19365 Summary: operator overloading set of mixin template is not considered Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: dkorpel live.nl I'm trying to mixin generic operator overloads for + and -, and then add specialized operators for * and /. Minimized code: ``` mixin template Operators() { int opBinary(string op: "+")(S rhs) {return 1;} } struct S { mixin Operators; int opBinary(string op: "*")(S rhs) {return 2;} } void main() { import std.stdio; S s; writeln(s * s); // 2 writeln(s + s); // incompatible types for (s) + (s) writeln(s.opBinary!"+"(s)); //`opBinary!"+"` does not match template declaration opBinary(string op : "*")(S rhs) } ``` While opBinary!"+" and opBinary!"*" work in isolation, the prescence of opBinary!"*" completely shadows the opBinary!"+" template in the mixin. I expect both the normal and mixed in opBinary templates to be operator overloading candidates. --
Nov 05 2018