Skip to content

Commit

Permalink
fix(codegen): maps from uint types to Bool (#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-trunov authored Aug 25, 2024
1 parent 8a232b0 commit b220e21
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/abi/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const MapFunctions: Map<string, AbiFunction> = 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]})`;
Expand Down
3 changes: 2 additions & 1 deletion src/test/codegen/all-contracts.tact
Original file line number Diff line number Diff line change
Expand Up @@ -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";
import "./var-scope-global-fun-shadowing-allowed";
import "./map-uint-bool-get";
9 changes: 9 additions & 0 deletions src/test/codegen/map-uint-bool-get.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
contract MapUintBool {
m: map<Int as uint64, Bool>;

receive() {
nativeThrowUnless(1024, self.m.get(0) == null);
self.m.set(0, true);
self.m.del(0);
}
}

0 comments on commit b220e21

Please sign in to comment.