# HG changeset patch # User Christian Kamm # Date 1235847510 -3600 # Node ID 39cf8fa483fd7679326c0baee27fc043b768a579 # Parent 010b8b67de1a77a5679a1b72f664cbe4f2028286 Error gracefully for +=, -=, *=, /= if rhs is complex but lhs isn't. diff -r 010b8b67de1a -r 39cf8fa483fd dmd/expression.c --- a/dmd/expression.c Sat Feb 28 17:44:53 2009 +0100 +++ b/dmd/expression.c Sat Feb 28 19:58:30 2009 +0100 @@ -8031,6 +8031,9 @@ e2 = e2->castTo(sc, e1->type); } e = this; + + if (e2->type->iscomplex() && !type->iscomplex()) + error("Cannot assign %s to %s", e2->type->toChars(), type->toChars()); } } return e; @@ -8080,6 +8083,9 @@ e2 = e2->castTo(sc, e1->type); } e = this; + + if (e2->type->iscomplex() && !type->iscomplex()) + error("Cannot assign %s to %s", e2->type->toChars(), type->toChars()); } return e; } @@ -8201,6 +8207,9 @@ e2 = e2->castTo(sc, t2); } } + + if (e2->type->iscomplex() && !type->iscomplex()) + error("Cannot assign %s to %s", e2->type->toChars(), type->toChars()); } return this; } @@ -8267,6 +8276,10 @@ return e; } } + + if (e2->type->iscomplex() && !type->iscomplex()) + error("Cannot assign %s to %s", e2->type->toChars(), type->toChars()); + return this; } diff -r 010b8b67de1a -r 39cf8fa483fd dmd2/expression.c --- a/dmd2/expression.c Sat Feb 28 17:44:53 2009 +0100 +++ b/dmd2/expression.c Sat Feb 28 19:58:30 2009 +0100 @@ -8063,6 +8063,9 @@ e2 = e2->castTo(sc, e1->type); } e = this; + + if (e2->type->iscomplex() && !type->iscomplex()) + error("Cannot assign %s to %s", e2->type->toChars(), type->toChars()); } } return e; @@ -8112,6 +8115,9 @@ e2 = e2->castTo(sc, e1->type); } e = this; + + if (e2->type->iscomplex() && !type->iscomplex()) + error("Cannot assign %s to %s", e2->type->toChars(), type->toChars()); } return e; } @@ -8233,6 +8239,9 @@ e2 = e2->castTo(sc, t2); } } + + if (e2->type->iscomplex() && !type->iscomplex()) + error("Cannot assign %s to %s", e2->type->toChars(), type->toChars()); } return this; } @@ -8299,6 +8308,10 @@ return e; } } + + if (e2->type->iscomplex() && !type->iscomplex()) + error("Cannot assign %s to %s", e2->type->toChars(), type->toChars()); + return this; }