-
Notifications
You must be signed in to change notification settings - Fork 191
feat(codegen): don't load contract state unless getter reads or writes it #3364
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
base: main
Are you sure you want to change the base?
Conversation
…self # Conflicts: # dev-docs/CHANGELOG.md # src/benchmarks/jetton/size.json # src/benchmarks/nft/size.json # src/benchmarks/notcoin/size.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contract Test {
get fun zero(): Int { // does not read state
return 0;
}
get fun bugTrigger() {
self.zero(); // invokes zero() via the non-mutating wrapper
}
}
->
FunC compilation error: /Users/daniil/Coding/tact/test.tact_Test.fc:63:28: error: cannot apply function $Test$_fun_zero : () -> ((), int) to arguments of type tuple: cannot unify type tuple with ()
$self~$Test$_fun_zero();
This optimization can incorrectly skip generating Example that breaks with current implementation: contract Child {
fun justForCodesDict(): StateInit {
return initOf Test();
}
}
fun helper(): StateInit {
// requires __tact_child_contract_codes initialized by $contract_load
return initOf Child();
}
contract Test {
x: Int = 0;
receive() {
self.x += 1;
}
get fun broken(): Cell {
// computeGettersEffects sees no storage access here
return helper().code;
}
}
You should enhance the analysis to recursively examine the bodies of static functions invoked by getters, ensuring proper detection of storage dependencies and preventing runtime errors caused by omitted |
Closes #3363.