Adjusts syntax tests to read-only array length.

This commit is contained in:
Erik Kundt
2019-11-19 21:11:09 +01:00
parent 5020e186da
commit d05afb34d6
12 changed files with 78 additions and 10 deletions
@@ -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.
@@ -0,0 +1,17 @@
contract A {
uint[] x;
}
contract B is A {
function g() public pure returns (uint) {
return A.x.length;
}
function h() public pure returns (uint) {
return A.x[2];
}
}
// ----
// 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".