-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10623 from ethereum/smt_const_expr
[SMTChecker] Apply const eval to arithmetic binary expressions
- Loading branch information
Showing
6 changed files
with
67 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
test/libsolidity/smtCheckerTests/operators/const_exp_1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pragma experimental SMTChecker; | ||
|
||
contract C { | ||
uint constant x = 2; | ||
uint constant y = x ** 10; | ||
|
||
function f() public view { | ||
assert(y == 2 ** 10); | ||
assert(y == 1024); | ||
assert(y == 14); // should fail | ||
} | ||
} | ||
// ---- | ||
// Warning 2018: (98-206): Function state mutability can be restricted to pure | ||
// Warning 6328: (172-187): CHC: Assertion violation happens here.\nCounterexample:\nx = 2, y = 1024\n\n\n\nTransaction trace:\nconstructor()\nState: x = 2, y = 1024\nf() |
13 changes: 13 additions & 0 deletions
13
test/libsolidity/smtCheckerTests/operators/constant_propagation_1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pragma experimental SMTChecker; | ||
|
||
contract C { | ||
uint constant DEPOSIT_CONTRACT_TREE_DEPTH = 32; | ||
uint constant MAX_DEPOSIT_COUNT = 2**DEPOSIT_CONTRACT_TREE_DEPTH - 1; | ||
function f() public pure { | ||
assert(DEPOSIT_CONTRACT_TREE_DEPTH == 32); | ||
assert(MAX_DEPOSIT_COUNT == 4294967295); | ||
assert(MAX_DEPOSIT_COUNT == 2); // should fail | ||
} | ||
} | ||
// ---- | ||
// Warning 6328: (284-314): CHC: Assertion violation happens here.\nCounterexample:\nDEPOSIT_CONTRACT_TREE_DEPTH = 32, MAX_DEPOSIT_COUNT = 4294967295\n\n\n\nTransaction trace:\nconstructor()\nState: DEPOSIT_CONTRACT_TREE_DEPTH = 32, MAX_DEPOSIT_COUNT = 4294967295\nf() |