[Issue 19365] New: operator overloading set of mixin template is not considered
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 5 11:28:33 UTC 2018
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 at puremagic.com
Reporter: dkorpel at 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.
--
More information about the Digitalmars-d-bugs
mailing list