mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Adjusts syntax tests to read-only array length.
This commit is contained in:
parent
5020e186da
commit
d05afb34d6
@ -4,4 +4,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (75-83): Calldata arrays cannot be resized.
|
||||
// TypeError: (75-83): Member "length" is read-only and cannot be used to resize arrays.
|
||||
|
@ -0,0 +1,8 @@
|
||||
contract c {
|
||||
uint[] storageArray;
|
||||
function f() public {
|
||||
storageArray.length = 3;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (72-91): Member "length" is read-only and cannot be used to resize arrays.
|
@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
mapping(uint => uint[]) map;
|
||||
function f() public {
|
||||
map[0].length = 4;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (80-93): Member "length" is read-only and cannot be used to resize arrays.
|
@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
struct S {
|
||||
uint[] a;
|
||||
}
|
||||
S s;
|
||||
function f() public {
|
||||
s.a.length = 4;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (95-105): Member "length" is read-only and cannot be used to resize arrays.
|
7
test/libsolidity/syntaxTests/array/pop/calldata_pop.sol
Normal file
7
test/libsolidity/syntaxTests/array/pop/calldata_pop.sol
Normal file
@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
function f(uint[] calldata x) external {
|
||||
x.pop();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (66-71): Member "pop" is not available in uint256[] calldata outside of storage.
|
8
test/libsolidity/syntaxTests/array/pop/memory_pop.sol
Normal file
8
test/libsolidity/syntaxTests/array/pop/memory_pop.sol
Normal file
@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
function f() public {
|
||||
uint[] memory x;
|
||||
x.pop();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (72-77): Member "pop" is not available in uint256[] memory outside of storage.
|
@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
function f(uint[] calldata x) external {
|
||||
x.push();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (66-72): Member "push" is not available in uint256[] calldata outside of storage.
|
8
test/libsolidity/syntaxTests/array/push/memory_push.sol
Normal file
8
test/libsolidity/syntaxTests/array/push/memory_push.sol
Normal file
@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
function f() public {
|
||||
uint[] memory x;
|
||||
x.push();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (72-78): Member "push" is not available in uint256[] memory outside of storage.
|
@ -5,4 +5,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (72-80): Memory arrays cannot be resized.
|
||||
// TypeError: (72-80): Member "length" is read-only and cannot be used to resize arrays.
|
||||
|
@ -0,0 +1,7 @@
|
||||
contract A {
|
||||
uint[] x;
|
||||
function g() public returns (uint) {
|
||||
return x.push();
|
||||
}
|
||||
}
|
||||
// ----
|
@ -0,0 +1,8 @@
|
||||
contract A {
|
||||
uint[] x;
|
||||
function f() public view returns (uint) {
|
||||
return x.push();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (88-96): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
@ -3,9 +3,6 @@ contract A {
|
||||
}
|
||||
|
||||
contract B is A {
|
||||
function f() public view {
|
||||
A.x.length = 2;
|
||||
}
|
||||
function g() public pure returns (uint) {
|
||||
return A.x.length;
|
||||
}
|
||||
@ -14,8 +11,7 @@ contract B is A {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (87-97): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// TypeError: (170-173): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError: (170-180): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError: (249-252): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError: (249-255): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError: (109-112): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError: (109-119): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError: (188-191): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError: (188-194): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
Loading…
Reference in New Issue
Block a user