Skip to content

Commit 35aab63

Browse files
committed
test: compound assignment LHS index single-evaluation
Pin down that the LHS index expression in a[f()] += v is evaluated exactly once. Complements viaYul/tuple_evaluation_order.sol.
1 parent 8471cf2 commit 35aab63

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
contract C {
2+
uint[3] data;
3+
uint counter;
4+
function nextIdx() internal returns (uint) { counter += 1; return counter - 1; }
5+
function f() public returns (uint c, uint a0, uint a1, uint a2) {
6+
data[0] = 100;
7+
data[1] = 200;
8+
data[2] = 300;
9+
data[nextIdx()] += 5;
10+
c = counter;
11+
(a0, a1, a2) = (data[0], data[1], data[2]);
12+
}
13+
}
14+
// ----
15+
// f() -> 1, 105, 200, 300

0 commit comments

Comments
 (0)