Disallow complex expressions on left-hand-sides of assignments.
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
https://github.com/ethereum/solidity/pull/13139 attempted to add some warnings about easy-to-miss dangling reference cases.
We could go beyond that and also warn about cases like this:
```
contract C {
uint[] x;
uint[] y;
function g() internal returns (uint[] storage) {
x.pop();
return y;
}
function f() public {
(x[x.length - 1], g()[1]) = (1, 2);
}
}
```
(which, roughly, we got reported as a bug bounty report)
In general we could warn about using most kinds of complex expressions on left-hand-sides of tuple assignments, especially about function calls.
We should also check if we can construct problematic cases in non-tuple assignments.
Contributor guide
Research direction
Review pull request #13139 and the tuple-assignment example in this issue first. Investigate how complex left-hand expressions are handled in tuple and non-tuple assignments, and consider the work complete when problematic cases are consistently diagnosed without missing the reported dangling-reference behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- blockchain, compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100