Merge pull request #5149 from ethereum/fix_assertion_on_inval_tuple_call

Fixes invalid function calls to literals inside tuple assignment's LHS.
This commit is contained in:
chriseth 2018-10-15 11:24:47 +02:00 committed by GitHub
commit 656adcaeb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -1444,8 +1444,12 @@ void TypeChecker::checkExpressionAssignment(Type const& _type, Expression const&
auto const* tupleType = dynamic_cast<TupleType const*>(&_type);
auto const& types = tupleType ? tupleType->components() : vector<TypePointer> { _type.shared_from_this() };
solAssert(tupleExpression->components().size() == types.size(), "");
for (size_t i = 0; i < types.size(); i++)
solAssert(
tupleExpression->components().size() == types.size() || m_errorReporter.hasErrors(),
"Array sizes don't match or no errors generated."
);
for (size_t i = 0; i < min(tupleExpression->components().size(), types.size()); i++)
if (types[i])
{
solAssert(!!tupleExpression->components()[i], "");

View File

@ -0,0 +1,9 @@
contract C {
function f(uint y) public pure {
(4(y)) = 2;
}
}
// ----
// TypeError: (59-63): Type is not callable
// TypeError: (59-63): Expression has to be an lvalue.
// TypeError: (67-68): Type int_const 2 is not implicitly convertible to expected type tuple().

View File

@ -0,0 +1,7 @@
contract C {
function f(uint y) public pure returns (uint) {
(f(y)) = 2;
}
}
// ----
// TypeError: (74-78): Expression has to be an lvalue.