solidity/test/libsolidity/semanticTests/array/push_no_args_struct.sol
Djordje Mijovic ad8d840ee7 [Sol->Yul] Implementing conversion of struct to struct pointer.
Co-authored-by: Daniel Kirchner <daniel@ekpyron.org>
2020-10-08 16:37:57 +02:00

47 lines
656 B
Solidity

contract C {
struct S {
uint x;
}
S[] array;
function f(uint y) public {
S storage s = array.push();
g(s, y);
}
function g(S storage s, uint y) internal {
s.x = y;
}
function h(uint y) public {
g(array.push(), y);
}
function lv(uint y) public {
array.push().x = y;
}
function a(uint i) public returns (uint) {
return array[i].x;
}
function l() public returns (uint) {
return array.length;
}
}
// ====
// compileViaYul: also
// ----
// l() -> 0
// f(uint256): 42 ->
// l() -> 1
// a(uint256): 0 -> 42
// h(uint256): 84 ->
// l() -> 2
// a(uint256): 1 -> 84
// lv(uint256): 4096 ->
// l() -> 3
// a(uint256): 2 -> 4096