Add control flow tests for "and" and "or" operators

This commit is contained in:
wechman
2022-09-28 13:06:25 +02:00
parent 43a612e420
commit 1084a34f28
8 changed files with 90 additions and 65 deletions
@@ -0,0 +1,11 @@
struct S { bool f; }
contract C {
function f() public view {
S storage s;
s.f && true;
}
}
// ----
// TypeError 3464: (95-96): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -0,0 +1,11 @@
struct S { bool f; }
contract C {
function f() public view {
S storage s;
s.f || true;
}
}
// ----
// TypeError 3464: (95-96): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
@@ -2,16 +2,25 @@ struct S { bool f; }
using {add as +} for S;
function add(S storage x, S storage) pure returns (S storage) { return x; }
function add(S storage _s, S storage) pure returns (S storage) {
return _s;
_s.f = true;
}
contract C {
S s;
function f() public {
S storage x = s;
S storage y;
x + y;
function get() private returns (S storage) {
S storage s;
return s;
}
function f() public {
S storage s;
get() + s;
}
}
// ----
// TypeError 3464: (230-231): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// Warning 5740: (131-142): Unreachable code.
// TypeError 3464: (238-239): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
// TypeError 3464: (311-312): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.