forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 14
/
VerifResults.sol
43 lines (37 loc) · 1004 Bytes
/
VerifResults.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0;
// Example demonstrating possible outcomes of verification
contract VerifResults {
int x;
// Constructor: OK
/// @notice postcondition x == 0
constructor() {
}
// Setting a value: OK
/// @notice modifies x
/// @notice postcondition x == x1
function set_correct(int x1) public {
x = x1;
}
// Setting a value: ERROR
/// @notice modifies x
/// @notice postcondition x == x1
function set_incorrect(int x1) public {
x = x1 + 1; // Wrong
}
// Unsupported feature, but can be specified
/// @notice modifies x
/// @notice postcondition x == 0
function unsupported() public pure {
assembly {
// ... set x to 0
}
}
// Relies on specification of unsupported
// function to prove assertion
/// @notice modifies x
function use_unsupported() public view {
unsupported();
assert(x == 0);
}
}