Error gracefully for +=, -=, *=, /= if rhs is complex but lhs isn't.

This commit is contained in:
Christian Kamm
2009-02-28 19:58:30 +01:00
parent 031474c724
commit b7febcf35a
2 changed files with 26 additions and 0 deletions

View File

@@ -8031,6 +8031,9 @@ Expression *AddAssignExp::semantic(Scope *sc)
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 @@ Expression *MinAssignExp::semantic(Scope *sc)
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 @@ Expression *MulAssignExp::semantic(Scope *sc)
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 @@ Expression *DivAssignExp::semantic(Scope *sc)
return e;
}
}
if (e2->type->iscomplex() && !type->iscomplex())
error("Cannot assign %s to %s", e2->type->toChars(), type->toChars());
return this;
}

View File

@@ -8063,6 +8063,9 @@ Expression *AddAssignExp::semantic(Scope *sc)
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 @@ Expression *MinAssignExp::semantic(Scope *sc)
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 @@ Expression *MulAssignExp::semantic(Scope *sc)
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 @@ Expression *DivAssignExp::semantic(Scope *sc)
return e;
}
}
if (e2->type->iscomplex() && !type->iscomplex())
error("Cannot assign %s to %s", e2->type->toChars(), type->toChars());
return this;
}