From b220e2137b70fef7a2772f0bcf368a3cfa268126 Mon Sep 17 00:00:00 2001 From: Anton Trunov Date: Sun, 25 Aug 2024 15:54:44 +0900 Subject: [PATCH] fix(codegen): maps from uint types to Bool (#725) --- CHANGELOG.md | 1 + src/abi/map.ts | 2 +- src/test/codegen/all-contracts.tact | 3 ++- src/test/codegen/map-uint-bool-get.tact | 9 +++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/test/codegen/map-uint-bool-get.tact diff --git a/CHANGELOG.md b/CHANGELOG.md index a2a2342fd..4e4b1d418 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Traits can override inherited abstract functions: PR [#724](https://github.com/tact-lang/tact/pull/724) +- Fix code generation bug for maps from unsigned integers to Boolean values: PR [#725](https://github.com/tact-lang/tact/pull/725) ## [1.4.4] - 2024-08-18 diff --git a/src/abi/map.ts b/src/abi/map.ts index a8a7c324c..f325eac18 100644 --- a/src/abi/map.ts +++ b/src/abi/map.ts @@ -271,7 +271,7 @@ export const MapFunctions: Map = new Map([ return `__tact_dict_get_${kind}_${vKind}(${resolved[0]}, ${bits}, ${resolved[1]}, ${vBits})`; } else if (self.value === "Bool") { ctx.used(`__tact_dict_get_${kind}_int`); - return `__tact_dict_get_int_int(${resolved[0]}, ${bits}, ${resolved[1]}, 1)`; + return `__tact_dict_get_${kind}_int(${resolved[0]}, ${bits}, ${resolved[1]}, 1)`; } else if (self.value === "Cell") { ctx.used(`__tact_dict_get_${kind}_cell`); return `__tact_dict_get_${kind}_cell(${resolved[0]}, ${bits}, ${resolved[1]})`; diff --git a/src/test/codegen/all-contracts.tact b/src/test/codegen/all-contracts.tact index 0365f68f0..6f69532ed 100644 --- a/src/test/codegen/all-contracts.tact +++ b/src/test/codegen/all-contracts.tact @@ -5,4 +5,5 @@ import "./struct-field-func-keywords-name-clash"; import "./message-opcode-parsing.tact"; import "./struct-with-default-and-optional-fields"; import "./mutating-method-on-non-lvalues"; -import "./var-scope-global-fun-shadowing-allowed"; \ No newline at end of file +import "./var-scope-global-fun-shadowing-allowed"; +import "./map-uint-bool-get"; \ No newline at end of file diff --git a/src/test/codegen/map-uint-bool-get.tact b/src/test/codegen/map-uint-bool-get.tact new file mode 100644 index 000000000..347f50d0c --- /dev/null +++ b/src/test/codegen/map-uint-bool-get.tact @@ -0,0 +1,9 @@ +contract MapUintBool { + m: map; + + receive() { + nativeThrowUnless(1024, self.m.get(0) == null); + self.m.set(0, true); + self.m.del(0); + } +}