1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

[FunC] Deprecate pragma allow-post-modification

All tests pass: it does not affect hashes (since modifying
variables in a single expression was an error)
This commit is contained in:
Aleksandr Kirsanov 2024-05-10 15:56:11 +03:00
parent bb86dc0f96
commit aaf3ca335d
No known key found for this signature in database
GPG key ID: B758BBAA01FFB3D3
5 changed files with 12 additions and 27 deletions

View file

@ -286,24 +286,17 @@ std::vector<var_idx_t> pre_compile_tensor(const std::vector<Expr *> args, CodeBl
res_lists[i] = args[i]->pre_compile(code, lval_globs);
for (size_t j = 0; j < res_lists[i].size(); ++j) {
TmpVar& var = code.vars.at(res_lists[i][j]);
if (code.flags & CodeBlob::_AllowPostModification) {
if (!lval_globs && (var.cls & TmpVar::_Named)) {
Op *op = &code.emplace_back(nullptr, Op::_Let, std::vector<var_idx_t>(), std::vector<var_idx_t>());
op->set_disabled();
var.on_modification.push_back([modified_vars, i, j, op, done = false](const SrcLocation &here) mutable {
if (!done) {
done = true;
modified_vars->push_back({i, j, op});
}
});
} else {
var.on_modification.push_back([](const SrcLocation &) {
});
}
if (!lval_globs && (var.cls & TmpVar::_Named)) {
Op *op = &code.emplace_back(nullptr, Op::_Let, std::vector<var_idx_t>(), std::vector<var_idx_t>());
op->set_disabled();
var.on_modification.push_back([modified_vars, i, j, op, done = false](const SrcLocation &here) mutable {
if (!done) {
done = true;
modified_vars->push_back({i, j, op});
}
});
} else {
var.on_modification.push_back([name = var.to_string()](const SrcLocation &here) {
throw src::ParseError{here, PSTRING() << "Modifying local variable " << name
<< " after using it in the same expression"};
var.on_modification.push_back([](const SrcLocation &) {
});
}
}