From 229ce26cf95023ceff3d754d2622501d70b83cb6 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:58:15 +0100 Subject: [PATCH] feat(docs): describe the limit for deeply nested expressions (#1101) This addresses issue #7 of Trail of Bits security audit (2024) --- CHANGELOG.md | 1 + docs/src/content/docs/book/expressions.mdx | 19 +++++++++++++++++++ docs/src/content/docs/book/operators.mdx | 19 +++++++++++++++++++ .../content/docs/cookbook/dexes/stonfi.mdx | 2 -- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99a91449f..0d00388b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Utility for logging errors in code that was supposed to be unreachable: PR [#991](https://github.com/tact-lang/tact/pull/991) - Docs: `preloadRef` method for the `Slice` type: PR [#1044](https://github.com/tact-lang/tact/pull/1044) - Docs: added DeDust cookbook: PR [#954](https://github.com/tact-lang/tact/pull/954) +- Docs: described the limit for deeply nested expressions: PR [#1101](https://github.com/tact-lang/tact/pull/1101) ### Changed diff --git a/docs/src/content/docs/book/expressions.mdx b/docs/src/content/docs/book/expressions.mdx index e60f38058..f9a61eb86 100644 --- a/docs/src/content/docs/book/expressions.mdx +++ b/docs/src/content/docs/book/expressions.mdx @@ -5,6 +5,25 @@ description: "This page lists all the expressions in Tact" Every operator in Tact forms an expression, but there's much more to uncover as Tact offers a wide range of expressive options to choose from. +:::note + + The current maximum allowed nesting level of expressions is $83$. An attempt to write a deeper expression will result in a compilation error: + + ```tact + fun elegantWeaponsForCivilizedAge(): Int { + return + (((((((((((((((((((((((((((((((( + (((((((((((((((((((((((((((((((( + (((((((((((((((((((( // 84 parens, compilation error! + 42 + )))))))))))))))))))) + )))))))))))))))))))))))))))))))) + )))))))))))))))))))))))))))))))); + } + ``` + +::: + ## Literals Literals represent values in Tact. These are fixed values—not variables—that you _literally_ provide in your code. All literals in Tact are expressions themselves. diff --git a/docs/src/content/docs/book/operators.mdx b/docs/src/content/docs/book/operators.mdx index ce8da971d..08ffc3f9a 100644 --- a/docs/src/content/docs/book/operators.mdx +++ b/docs/src/content/docs/book/operators.mdx @@ -98,6 +98,25 @@ Parentheses (also can be called round brackets, `(){:tact}`) are more of a punct 5 * (5 - 2); // 15 ``` +:::note + + The current maximum allowed nesting level of expressions is $83$. An attempt to write a deeper expression will result in a compilation error: + + ```tact + fun elegantWeaponsForCivilizedAge(): Int { + return + (((((((((((((((((((((((((((((((( + (((((((((((((((((((((((((((((((( + (((((((((((((((((((( // 84 parens, compilation error! + 42 + )))))))))))))))))))) + )))))))))))))))))))))))))))))))) + )))))))))))))))))))))))))))))))); + } + ``` + +::: + ## Unary Unary here means that they are applied only to one operand of the given expression. All unary operators, except for the [non-null assertion](#unary-non-null-assert), are of the same [precedence](#precedence). diff --git a/docs/src/content/docs/cookbook/dexes/stonfi.mdx b/docs/src/content/docs/cookbook/dexes/stonfi.mdx index 4443d9c33..7bc876479 100644 --- a/docs/src/content/docs/cookbook/dexes/stonfi.mdx +++ b/docs/src/content/docs/cookbook/dexes/stonfi.mdx @@ -5,8 +5,6 @@ sidebar: order: 2 --- -# STON.fi - [STON.fi](https://ston.fi) is a decentralized automated market maker (AMM) built on [TON blockchain](https://ton.org) providing virtually zero fees, low slippage, an extremely easy interface, and direct integration with TON wallets. :::caution