mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Sol->Yul] Implementing struct copying from memory to storage
This commit is contained in:
@@ -4,15 +4,16 @@ contract C {
|
||||
struct S {
|
||||
uint256 a;
|
||||
uint256 b;
|
||||
bytes2 c;
|
||||
}
|
||||
|
||||
function f(S calldata s) external pure returns (uint256, uint256) {
|
||||
function f(S calldata s) external pure returns (uint256, uint256, byte) {
|
||||
S memory m = s;
|
||||
return (m.a, m.b);
|
||||
return (m.a, m.b, m.c[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint256,uint256)): 42, 23 -> 42, 23
|
||||
// f((uint256,uint256, bytes2)): 42, 23, "ab" -> 42, 23, "b"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
uint32 a;
|
||||
uint128 b;
|
||||
uint256 c;
|
||||
}
|
||||
|
||||
struct X {
|
||||
uint256 a;
|
||||
S s;
|
||||
}
|
||||
|
||||
uint[79] r;
|
||||
X x;
|
||||
|
||||
function f() external returns (uint32, uint128, uint256) {
|
||||
X memory m = X(12, S(42, 23, 34));
|
||||
x = m;
|
||||
return (x.s.a, x.s.b, x.s.c);
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 42, 23, 34
|
||||
@@ -10,5 +10,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// s() -> 1, true
|
||||
|
||||
Reference in New Issue
Block a user