Fix ICE on invalid tuple assignments.

This commit is contained in:
Daniel Kirchner 2022-08-09 12:40:00 +02:00
parent bb1a8df97e
commit 9a429e2300
3 changed files with 26 additions and 1 deletions

View File

@ -10,6 +10,7 @@ Compiler Features:
Bugfixes:
* Type Checker: Fix internal compiler error on tuple assignments with invalid left-hand side.
### 0.8.16 (2022-08-08)

View File

@ -166,8 +166,15 @@ void TypeChecker::checkDoubleStorageAssignment(Assignment const& _assignment)
);
}
};
TupleExpression const* lhsTupleExpression = dynamic_cast<TupleExpression const*>(&_assignment.leftHandSide());
if (!lhsTupleExpression)
{
solAssert(m_errorReporter.hasErrors());
return;
}
count(
dynamic_cast<TupleExpression const&>(_assignment.leftHandSide()),
*lhsTupleExpression,
dynamic_cast<TupleType const&>(*type(_assignment.rightHandSide())),
count
);

View File

@ -0,0 +1,17 @@
contract C {
function f() internal pure {}
function g() internal pure returns (uint256) {}
function h() internal pure returns (uint256, uint256) {}
function test() public pure {
f() = ();
g() = (uint256(1));
h() = (uint256(1), uint256(2));
h() = ();
}
}
// ----
// TypeError 4247: (184-187): Expression has to be an lvalue.
// TypeError 4247: (196-199): Expression has to be an lvalue.
// TypeError 4247: (218-221): Expression has to be an lvalue.
// TypeError 4247: (252-255): Expression has to be an lvalue.
// TypeError 7407: (258-260): Type tuple() is not implicitly convertible to expected type tuple(uint256,uint256).