Static Analyzer for Solidity
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
slither/tests/detectors/assert-state-change/0.7.6/assert_state_change.sol

39 lines
760 B

contract A {
uint s_a;
/* Direct state change in assert is NOT ok */
function bad0() public {
assert((s_a += 1) > 10);
}
/* Direct state change in assert is NOT ok */
function bad1(uint256 a) public {
assert((s_a += a) > 10);
}
/* State change via functions calls in assert is NOT ok */
function bad2_callee() public returns (bool) {
return (s_a += 1) > 10;
}
function bad2() public {
assert(bad2_callee());
}
/* Parameter use is ok */
function good0(uint256 a) public {
assert(a > 10);
}
/* Parameter change is ok */
function good1(uint256 a) public {
assert((a += 1) > 10);
}
/* State change in require is ok */
function good2(uint256 a) public {
require(a == (s_a += 1));
}
}