tact icon indicating copy to clipboard operation
tact copied to clipboard

Calling mutating methods on constants fails with a FunC compilation error

Open anton-trunov opened this issue 6 months ago • 0 comments

extends mutates fun inc(self: Int) {
    self += 1;
}

const C1: Int = 42;

contract Test {

    get fun foo(): Int {
        42.inc(); // this is fine
        C1.inc(); // <---- produces FunC compilation error
        return 42;
    }
}

fails to compile with the following error message:

error: lvalue expected before `~$Int$_fun_inc`
      42~$Int$_fun_inc();

It seems to me a not_mut wrapper does not get applied in this case.

anton-trunov avatar Aug 09 '24 09:08 anton-trunov