Skip to content

Commit 6b60524

Browse files
authored
Merge pull request #13367 from ethereum/invalidTupleAssignment
Fix ICE on invalid tuple assignments.
2 parents bb1a8df + 9a429e2 commit 6b60524

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Compiler Features:
1010

1111

1212
Bugfixes:
13+
* Type Checker: Fix internal compiler error on tuple assignments with invalid left-hand side.
1314

1415

1516
### 0.8.16 (2022-08-08)

libsolidity/analysis/TypeChecker.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,15 @@ void TypeChecker::checkDoubleStorageAssignment(Assignment const& _assignment)
166166
);
167167
}
168168
};
169+
170+
TupleExpression const* lhsTupleExpression = dynamic_cast<TupleExpression const*>(&_assignment.leftHandSide());
171+
if (!lhsTupleExpression)
172+
{
173+
solAssert(m_errorReporter.hasErrors());
174+
return;
175+
}
169176
count(
170-
dynamic_cast<TupleExpression const&>(_assignment.leftHandSide()),
177+
*lhsTupleExpression,
171178
dynamic_cast<TupleType const&>(*type(_assignment.rightHandSide())),
172179
count
173180
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
contract C {
2+
function f() internal pure {}
3+
function g() internal pure returns (uint256) {}
4+
function h() internal pure returns (uint256, uint256) {}
5+
function test() public pure {
6+
f() = ();
7+
g() = (uint256(1));
8+
h() = (uint256(1), uint256(2));
9+
h() = ();
10+
}
11+
}
12+
// ----
13+
// TypeError 4247: (184-187): Expression has to be an lvalue.
14+
// TypeError 4247: (196-199): Expression has to be an lvalue.
15+
// TypeError 4247: (218-221): Expression has to be an lvalue.
16+
// TypeError 4247: (252-255): Expression has to be an lvalue.
17+
// TypeError 7407: (258-260): Type tuple() is not implicitly convertible to expected type tuple(uint256,uint256).

0 commit comments

Comments
 (0)