Fixes invalid function calls to literals inside tuple assignment's LHS.

This commit is contained in:
Christian Parpart 2018-10-05 15:38:14 +02:00 committed by Christian Parpart
parent 26dc876c28
commit 6d815a142f
No known key found for this signature in database
GPG Key ID: 19BC8DD20312C929
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.