mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
28 lines
554 B
Solidity
28 lines
554 B
Solidity
|
library Lib {
|
||
|
struct Data { uint a; uint[] b; }
|
||
|
function set(Data storage _s) public
|
||
|
{
|
||
|
_s.a = 7;
|
||
|
while (_s.b.length < 20)
|
||
|
_s.b.push();
|
||
|
_s.b[19] = 8;
|
||
|
}
|
||
|
}
|
||
|
contract Test {
|
||
|
mapping(string => Lib.Data) data;
|
||
|
function f() public returns (uint a, uint b)
|
||
|
{
|
||
|
Lib.set(data["abc"]);
|
||
|
a = data["abc"].a;
|
||
|
b = data["abc"].b[19];
|
||
|
}
|
||
|
}
|
||
|
// ====
|
||
|
// compileToEwasm: false
|
||
|
// compileViaYul: also
|
||
|
// ----
|
||
|
// library: Lib
|
||
|
// f() -> 7, 8
|
||
|
// gas irOptimized: 101869
|
||
|
// gas legacy: 101504
|