Closed zhao-nan closed 4 years ago
Function inc doesn't return anything, the way you wrote the contract both functions write into a state variable but always return zero.
To refer to the return value you need to name the return value 'returns (int res)'.
The following contract verifies fine
contract Test {
/// @notice postcondition res == x + 1
function callInc(int x) public returns (int res) {
res = inc(x);
}
/// @notice postcondition res == x + 1
function inc(int x) public returns (int res) {
res = x+1;
}
}
Description
In the above contract, both function contracts should be verifiable. However, solc-verify reports that the first postcondition might not hold.
Environment
Semi-Related question
is it possible to refer to a function's return value? If so, how? In the above, I actually do not want a global
res
variable, but I could not find another way to express this.