mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add control flow tests for "and" and "or" operators
This commit is contained in:
@@ -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.
|
||||
+16
-7
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user