To see why it fails, consider the following counter-example
pragma solidity ^0.8.10;
contract Return {
int counter;
function test(uint x) public returns (int) {
if (x > 0) {
return -1;
}
counter++; // <--- this would NOT run if -1 is returned
return 1;
}
}
It transpiles to
contract Return {
@state
int counter;
public function unlock(){
require(true);
}
function test(int x) : int {
int ret = 0;
bool returned = false;
if (x > 0) {
if (!returned) {
returned = true;
ret = -1;
}
}
this.counter++; // <--- this would run even if -1 is returned
return returned ? ret : 1;
}
}
To see why it fails, consider the following counter-example
It transpiles to