Adjusts syntax tests to read-only array length.

This commit is contained in:
Erik Kundt 2019-09-18 15:36:45 +02:00
parent 5020e186da
commit d05afb34d6
12 changed files with 78 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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

View 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.

View 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.

View File

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

View 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.

View File

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

View File

@ -0,0 +1,7 @@
contract A {
uint[] x;
function g() public returns (uint) {
return x.push();
}
}
// ----

View File

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

View File

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