Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure function from lib potentially modifies the state #41

Closed
laugan-ton opened this issue Mar 19, 2021 · 2 comments
Closed

Pure function from lib potentially modifies the state #41

laugan-ton opened this issue Mar 19, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@laugan-ton
Copy link

laugan-ton commented Mar 19, 2021

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.

@joydark joydark added the enhancement New feature or request label Apr 28, 2021
@ilyar
Copy link

ilyar commented Dec 16, 2021

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

@cryshado
Copy link
Contributor

No longer relevant in new compiler versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants