mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Adding more tests for array copying from storage to storage.
This commit is contained in:
parent
28e01202af
commit
bd86588459
@ -0,0 +1,19 @@
|
||||
contract c {
|
||||
uint64[] data1;
|
||||
uint256[] data2;
|
||||
|
||||
function test() public returns (uint256 x, uint256 y) {
|
||||
data2.push(11);
|
||||
data1.push(0);
|
||||
data1.push(1);
|
||||
data1.push(2);
|
||||
data1.push(3);
|
||||
data1.push(4);
|
||||
data2 = data1;
|
||||
assert(data1[0] == data2[0]);
|
||||
x = data2.length;
|
||||
y = data2[4];
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// test() -> 5, 4
|
@ -0,0 +1,22 @@
|
||||
contract c {
|
||||
uint256[] data1;
|
||||
uint256[] data2;
|
||||
|
||||
function test() public returns (uint256 x, uint256 y) {
|
||||
data2.push(11);
|
||||
data1.push(0);
|
||||
data1.push(1);
|
||||
data1.push(2);
|
||||
data1.push(3);
|
||||
data1.push(4);
|
||||
data2 = data1;
|
||||
assert(data1[0] == data2[0]);
|
||||
x = data2.length;
|
||||
y = data2[4];
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> 5, 4
|
@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
byte[32] data1;
|
||||
bytes2[10] data2;
|
||||
function f() external {
|
||||
data1 = data2;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7407: (99-104): Type bytes2[10] storage ref is not implicitly convertible to expected type bytes1[32] storage ref.
|
@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
uint64[32] data1;
|
||||
uint256[10] data2;
|
||||
function f() external {
|
||||
data1 = data2;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7407: (102-107): Type uint256[10] storage ref is not implicitly convertible to expected type uint64[32] storage ref.
|
@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
uint256[10] data1;
|
||||
uint256[] data2;
|
||||
function f() external {
|
||||
data1 = data2;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7407: (101-106): Type uint256[] storage ref is not implicitly convertible to expected type uint256[10] storage ref.
|
@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
uint256[10] data1;
|
||||
uint256[18] data2;
|
||||
function f() external {
|
||||
data1 = data2;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7407: (103-108): Type uint256[18] storage ref is not implicitly convertible to expected type uint256[10] storage ref.
|
Loading…
Reference in New Issue
Block a user