Disallow compound assignment for tuples.

This commit is contained in:
chriseth 2017-03-06 14:50:00 +01:00
parent 276229cc58
commit 93ef7fd260

View File

@ -947,6 +947,11 @@ bool TypeChecker::visit(Assignment const& _assignment)
_assignment.annotation().type = t; _assignment.annotation().type = t;
if (TupleType const* tupleType = dynamic_cast<TupleType const*>(t.get())) if (TupleType const* tupleType = dynamic_cast<TupleType const*>(t.get()))
{ {
if (_assignment.assignmentOperator() != Token::Assign)
typeError(
_assignment.location(),
"Compound assignment is not allowed for tuple types."
);
// Sequenced assignments of tuples is not valid, make the result a "void" type. // Sequenced assignments of tuples is not valid, make the result a "void" type.
_assignment.annotation().type = make_shared<TupleType>(); _assignment.annotation().type = make_shared<TupleType>();
expectType(_assignment.rightHandSide(), *tupleType); expectType(_assignment.rightHandSide(), *tupleType);