mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Adding tests for copying structs with function pointers between storage and memory
This commit is contained in:
parent
1fab5b79fb
commit
a740cb619b
@ -0,0 +1,33 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
uint32 a;
|
||||
uint128 b;
|
||||
uint256 c;
|
||||
function() internal returns (uint32) f;
|
||||
}
|
||||
|
||||
struct X {
|
||||
uint256 a;
|
||||
S s;
|
||||
}
|
||||
|
||||
uint[79] r;
|
||||
X x;
|
||||
|
||||
function f() external returns (uint32, uint128, uint256, uint32, uint32) {
|
||||
X memory m = X(12, S(42, 23, 34, g));
|
||||
x = m;
|
||||
return (x.s.a, x.s.b, x.s.c, x.s.f(), m.s.f());
|
||||
}
|
||||
|
||||
function g() internal returns (uint32) {
|
||||
return x.s.a;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: false
|
||||
// ----
|
||||
// f() -> 42, 23, 34, 42, 42
|
@ -0,0 +1,32 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
uint32 a;
|
||||
uint128 b;
|
||||
uint256 c;
|
||||
function() internal returns (uint32) f;
|
||||
}
|
||||
|
||||
struct X {
|
||||
uint256 a;
|
||||
S s;
|
||||
}
|
||||
|
||||
uint[79] arr;
|
||||
X x = X(12, S(42, 23, 34, g));
|
||||
|
||||
function f() external returns (uint32, uint128, uint256, uint32, uint32) {
|
||||
X memory m = x;
|
||||
return (m.s.a, m.s.b, m.s.c, m.s.f(), x.s.f());
|
||||
}
|
||||
|
||||
function g() internal returns (uint32) {
|
||||
return x.s.a;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: false
|
||||
// ----
|
||||
// f() -> 42, 23, 34, 42, 42
|
Loading…
Reference in New Issue
Block a user