solidity/test/libsolidity/smtCheckerTests/control_flow/revert.sol

37 lines
944 B
Solidity
Raw Normal View History

contract C {
function f() pure public {
2020-09-11 19:49:04 +00:00
revert();
// This is not reachable.
assert(false);
}
function g() pure public {
2020-09-11 19:49:04 +00:00
revert("revert message");
// This is not reachable.
assert(false);
}
2020-09-11 19:49:04 +00:00
function h(bool b) pure public {
if (b)
revert();
assert(!b);
}
// Check that arguments are evaluated.
bool x = false;
function m() view internal returns (string memory) {
assert(x != true);
}
function i() public {
x = true;
revert(m());
}
}
2021-03-31 15:11:54 +00:00
// ====
// SMTEngine: all
// ----
2021-03-31 15:11:54 +00:00
// Warning 5740: (83-96): Unreachable code.
// Warning 5740: (188-201): Unreachable code.
// Warning 6321: (375-388): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 6328: (394-411): CHC: Assertion violation happens here.\nCounterexample:\nx = true\n\nTransaction trace:\nC.constructor()\nState: x = false\nC.i()\n C.m() -- internal call