mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1749 from ethereum/compoundForTuples
Disallow compound assignment for tuples.
This commit is contained in:
commit
69a06fe163
@ -12,6 +12,7 @@ Bugfixes:
|
||||
* Commandline interface: Do not try creating paths ``.`` and ``..``.
|
||||
* Parser: Disallow octal literals.
|
||||
* Type system: Fix a crash caused by continuing on fatal errors in the code.
|
||||
* Type system: Disallow compound assignment for tuples.
|
||||
* Type system: Detect cyclic dependencies between constants.
|
||||
* Type system: Disallow arrays with negative length.
|
||||
* Type system: Fix a crash related to invalid binary operators.
|
||||
|
@ -947,6 +947,11 @@ bool TypeChecker::visit(Assignment const& _assignment)
|
||||
_assignment.annotation().type = t;
|
||||
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.
|
||||
_assignment.annotation().type = make_shared<TupleType>();
|
||||
expectType(_assignment.rightHandSide(), *tupleType);
|
||||
|
@ -2992,6 +2992,18 @@ BOOST_AUTO_TEST_CASE(tuple_assignment_from_void_function)
|
||||
CHECK_ERROR(text, TypeError, "Cannot declare variable with void (empty tuple) type.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(tuple_compound_assignment)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract C {
|
||||
function f() returns (uint a, uint b) {
|
||||
(a, b) += (1, 1);
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Compound assignment is not allowed for tuple types.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(member_access_parser_ambiguity)
|
||||
{
|
||||
char const* text = R"(
|
||||
|
Loading…
Reference in New Issue
Block a user