mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix inline assembly assignments to calldata structs and statically-sized arrays.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f(uint[2][2] calldata x) public returns (uint[2][2] memory r) {
|
||||
assembly { x := 0x24 }
|
||||
r = x;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256[2][2]): 0x0, 8, 7, 6, 5 -> 8, 7, 6, 5
|
||||
@@ -0,0 +1,18 @@
|
||||
pragma abicoder v2;
|
||||
|
||||
contract C {
|
||||
struct S { uint256 x; }
|
||||
struct S2 { uint256 x; uint256 y; }
|
||||
function f(S calldata s, S2 calldata s2) public pure returns (uint256 r, uint256 r2) {
|
||||
assembly {
|
||||
s := s2
|
||||
s2 := 4
|
||||
}
|
||||
r = s.x;
|
||||
r2 = s2.x;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f((uint256),(uint256,uint256)): 0x42, 0x07, 0x77 -> 0x07, 0x42
|
||||
@@ -0,0 +1,23 @@
|
||||
pragma abicoder v2;
|
||||
contract C {
|
||||
struct S { int8 x; int8 y; }
|
||||
function f() internal pure returns(S calldata s) {
|
||||
assembly {
|
||||
s := 0x24
|
||||
}
|
||||
}
|
||||
function g() public pure returns(int8, int8) {
|
||||
S calldata s = f();
|
||||
return (s.x, s.y);
|
||||
}
|
||||
function h() public pure returns(uint256) { f(); return 0x42; }
|
||||
function i() public pure returns(uint256) { abi.decode(msg.data[4:], (S)); return 0x42; }
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g(): 0xCAFFEE, 0x42, 0x21 -> 0x42, 0x21
|
||||
// g(): 0xCAFFEE, 0x4242, 0x2121 -> FAILURE
|
||||
// g(): 0xCAFFEE, 0x42 -> 0x42, 0
|
||||
// h() -> 0x42
|
||||
// i() -> FAILURE
|
||||
Reference in New Issue
Block a user