TVM-Solidity-Compiler icon indicating copy to clipboard operation
TVM-Solidity-Compiler copied to clipboard

Pure function from lib potentially modifies the state

Open laugan-ton opened this issue 3 years ago • 1 comments

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.

laugan-ton avatar Mar 19 '21 08:03 laugan-ton

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

ilyar avatar Dec 16 '21 15:12 ilyar

No longer relevant in new compiler versions

cryshado avatar Mar 23 '23 17:03 cryshado