Adding tests for copying structs with function pointers between storage and memory

This commit is contained in:
Djordje Mijovic 2020-09-01 15:56:55 +02:00
parent 1fab5b79fb
commit a740cb619b
2 changed files with 65 additions and 0 deletions

View File

@ -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

View File

@ -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