Ambiguous virtual function
Dennis
dkorpel at gmail.com
Thu Dec 6 09:21:10 UTC 2018
On Thursday, 6 December 2018 at 07:37:12 UTC, John Chapman wrote:
> Is the compiler giving the non-mixed-in function special
> treatment?
I think you're running into this bug:
https://issues.dlang.org/show_bug.cgi?id=19365
I see that it is not limited to operator overloading, in general
the overload set directly put into a struct/class completely
overrides the overload set from mixin templates. mixin strings
seem to work fine, so you can use those as temporary workaround.
Example:
```
mixin template F() {
int fun(int i) {return i;}
}
struct S {
mixin F; // (1)
mixin(`int fun(int i) {return i;}`); // (2)
string fun(string s) {return s;} // (3)
}
void main() {
import std.stdio;
S().fun(1).writeln();
}
```
With only the mixin template (1) it works, adding an overload (3)
breaks it, though adding the string mixin (2) fixes it even
though it should be ambiguous with (1).
More information about the Digitalmars-d-learn
mailing list