Skip to content

Commit 1538e32

Browse files
committed
Add caution about dictionaries with mixed keys
1 parent 34669a4 commit 1538e32

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docs/develop/func/stdlib.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,11 @@ int cell_null?(cell c) asm "ISNULL";
673673
Checks whether `c` is a `null`. Usually a `null`-cell represents an empty dictionary. FunC also has polymorphic `null?` built-in. (See [built-ins](/develop/func/builtins#other-primitives).)
674674

675675
## Dictionaries primitives
676+
677+
:::caution
678+
The dictionary primitives below are low-level and do not check that the structure of the cell, they are applied to, matches the operation signature. Applying a dictionary operation to a "non-dictionary" or applying an operation corresponding to one key length/sign to a dictionary with a different kind of keys, for instance simultaneous writing to one dictionary key-values with 8bit-signed key and 7bit-unsigned key, is **Undefined Behavior**. Often in such cases an exception is thrown, but in rare cases the wrong value can be written / read. Developers are strongly encouraged to avoid such code.
679+
:::
680+
676681
As said in [TVM.pdf](https://ton.org/tvm.pdf):
677682
> Dictionaries admit two different representations as TVM stack values:
678683
> * A slice `s` with a serialization of a TL-B value of type `HashmapE(n, X)`. In other words, `s` consists either of one bit equal to zero (if the dictionary is empty) or of one bit equal to one and a reference to a cell containing the root of the binary tree, i.e., a serialized value of type `Hashmap(n, X)`.

0 commit comments

Comments
 (0)