From 14d3052993996dd7754c587cadeb9f7bae1b07d6 Mon Sep 17 00:00:00 2001 From: Daniil Sedov Date: Fri, 16 Aug 2024 13:49:21 +0300 Subject: [PATCH] fix: only generate non-modifying native function once (#699) --- CHANGELOG.md | 1 + src/generator/writers/writeFunction.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8558b555d..94f9236fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Remainder fields in the middle of a struct are now forbidden: PR [#697](https://github.com/tact-lang/tact/pull/697) +- Defining two native functions from the same FunC function now does not fail compilation: PR [#699](https://github.com/tact-lang/tact/pull/699) ## [1.4.3] - 2024-08-16 diff --git a/src/generator/writers/writeFunction.ts b/src/generator/writers/writeFunction.ts index 885e7116f..00407e2df 100644 --- a/src/generator/writers/writeFunction.ts +++ b/src/generator/writers/writeFunction.ts @@ -521,7 +521,7 @@ export function writeFunction(f: FunctionDescription, ctx: WriterContext) { // Do not write native functions if (f.ast.kind === "native_function_decl") { - if (f.isMutating) { + if (f.isMutating && !ctx.isRendered(idText(f.ast.nativeName))) { // Write same function in non-mutating form const nonMutName = ops.nonModifying(idText(f.ast.nativeName)); ctx.fun(nonMutName, () => { @@ -544,6 +544,7 @@ export function writeFunction(f: FunctionDescription, ctx: WriterContext) { ); }); }); + ctx.markRendered(idText(f.ast.nativeName)); } return; }