solidity/test/libsolidity/semanticTests/libraries/using_library_structs.sol
Daniel Kirchner 44da8507b1 Change default EVM version to Shanghai.
Co-authored-by: Rodrigo Q. Saramago <rodrigoqsaramago@gmail.com>
2023-05-08 16:34:23 +02:00

27 lines
531 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
// ----
// library: Lib
// f() -> 7, 8
// gas irOptimized: 101818
// gas legacy: 101429