tact
tact copied to clipboard
Compiler allows changing fields in getter functions
Are you using the latest released (or pre-released, a.k.a. "next") version?
- [X] I'm using the latest Tact version
Tact source code
extends mutates fun changeMe(self: Int) {
self = 10;
}
contract Test {
a: Int = 5;
get fun changeFieldDirectly(): Int {
self.a = 10;
return self.a;
}
get fun changeFieldByCopyingContract(): Int {
let contract_copy = self;
contract_copy.a = 10;
self = contract_copy;
return self.a;
}
get fun changeFieldByMutatingFun(): Int {
self.a.changeMe();
return self.a;
}
}
Relevant Tact/build system log output
No response
What happened?
In the above code, no error is reported, even though field self.a
is being changed in three different ways in getter functions.
What did you expect?
An error stating that self.a
or self
cannot be assigned in getter functions. The semantics of getter functions state that they cannot change the contract state.
Steps to reproduce
No response
How do you run Tact?
Tact CLI
Anything else?
No response