| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/fail297.d(31): Error: operator `+` is not defined for type `Bar` |
| 5 |
fail_compilation/fail297.d(25): perhaps overload the operator with `auto opBinary(string op : "+")(const(Bar) rhs) {}` |
| 6 |
--- |
| 7 |
*/ |
| 8 |
|
| 9 |
// https://issues.dlang.org/show_bug.cgi?id=1969 |
| 10 |
// ICE(cod1.c) using undefined operator with one const operand |
| 11 |
// ICE or wrong-code. D2 only. Internal error: backend\cod1.c 1673 |
| 12 |
/* Root cause: BinExp::typeCombine() is checking for an _exact_ match, but |
| 13 |
typeMerge() will return success. |
| 14 |
|
| 15 |
PATCH: cast.c BinExp::typeCombine(). |
| 16 |
Compare the immutable versions of the types, instead of the types themselves. |
| 17 |
|
| 18 |
if (op == TOKmin || op == TOKadd) |
| 19 |
{ |
| 20 |
if (t1->ito == t2->ito && (t1->ty == Tstruct || t1->ty == Tclass)) |
| 21 |
goto Lerror; |
| 22 |
} |
| 23 |
*/ |
| 24 |
|
| 25 |
struct Bar {} |
| 26 |
|
| 27 |
const(Bar) baz() { return Bar(); } |
| 28 |
|
| 29 |
void foo() |
| 30 |
{ |
| 31 |
Bar result = Bar() + baz(); |
| 32 |
} |