2021-01-06 14:55:26 +00:00
|
|
|
pragma experimental SMTChecker;
|
|
|
|
contract C {
|
|
|
|
int x;
|
|
|
|
|
|
|
|
function g() public {
|
|
|
|
x = 42;
|
|
|
|
}
|
|
|
|
|
|
|
|
function f() public {
|
|
|
|
x = 1;
|
|
|
|
bool success = false;
|
|
|
|
try this.g() {
|
|
|
|
success = true;
|
|
|
|
assert(x == 42); // should hold
|
|
|
|
} catch Error (string memory /*reason*/) {
|
|
|
|
assert(x == 1); // should hold
|
|
|
|
} catch (bytes memory /*reason*/) {
|
|
|
|
assert(x == 1); // should hold
|
|
|
|
}
|
|
|
|
assert((success && x == 42) || (!success && x == 1)); // should hold
|
|
|
|
assert(success); // can fail
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ----
|
2021-01-06 15:34:16 +00:00
|
|
|
// Warning 6328: (447-462): CHC: Assertion violation happens here.\nCounterexample:\nx = 1\n\nTransaction trace:\nC.constructor()\nState: x = 0\nC.f()
|