TVM-Solidity-Compiler
TVM-Solidity-Compiler copied to clipboard
Pure function from lib potentially modifies the state
Here is what I get:
Error: Function declared as view, but this expression (potentially) modifies the state and thus requires the default.
File (ErrorA.sol):
pragma ton-solidity >=0.38.2;
library A {
function calc(uint128 value) public pure returns (uint128) {
return value++;
}
}
contract B {
uint128 constant VAL = 1;
function make() external view {
A.calc(VAL);
}
}
As you can see there are:
- no state variables that can be modified
- all vars are constants
- library function is pure itself.
Still, compiler shows error. Tested with 0.38.2.
the error is not reproduced since v0.51.0
version:
npx tondev sol set --compiler 0.51.0 --stdlib 0.51.0
npx tondev sol compile ErrorA.sol
No longer relevant in new compiler versions