I'm using Adam's workaround from https://issues.dlang.org/show_bug.cgi?id=19365, but now I have endless recursion. Reduced code:

```
mixin template operators() {
    S opBinary(string op: "+")(S rhs) {
        return rhs;
    }

    // (A)
    auto opBinary(string op, T)(T rhs) if (false) {
        return rhs;
    }
}

struct S {
    mixin operators ops;
    S opBinary(string op, T)(T a) {
        return ops.opBinary!op(a);
    }
}

void main() {
    S.init.opBinary!"+"(S.init);
}
```

Believe it or not, `ops.opBinary!op(a);` doesn't call anything from the mixin template ops, but it calls itself and it results in a stack overflow. I think this is a bug, but last time I was wrong, so maybe someone can explain what's going on here.

Note that after removing the opBinary at (A), it works. The idea behind it is that it converts the rhs to an S that opBinary!"+" takes. A less reduced version would be:

```
auto opBinary(string op, T)(T rhs) if (!is(T==S)) {
    return this.opBinary!op(S(rhs));
}
```

Does anyone know how to get this working?

Reply via email to