Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 0953a69

Browse files
authored
Add known_to_abort documentation (#980)
1 parent e836fe7 commit 0953a69

File tree

1 file changed

+10
-0
lines changed
  • apps/nextra/pages/en/build/smart-contracts

1 file changed

+10
-0
lines changed

apps/nextra/pages/en/build/smart-contracts/linter.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ It is a common Move pattern to provide inline specifications in conditions, espe
5959

6060
Note that an `assert!` is translated to a conditional abort, so blocks in `assert!` condition also are reported by this lint.
6161

62+
### `known_to_abort`
63+
64+
Checks for expressions that will always abort at runtime due to known constant values that violate runtime constraints. This lint helps identify code that will deterministically fail before it reaches production.
65+
66+
The following cases are detected:
67+
68+
- **Bit shifts with excessive shift amounts**: `x << n` or `x >> n` where `n` is a constant that is greater than or equal to the bit width of `x`'s type. For example, `value << 64` when `value` is of type `u64` will always abort.
69+
- **Division or modulo by zero**: `x / 0` or `x % 0` operations will always abort at runtime.
70+
- **Out-of-range type casting**: `constant as type` where the `constant` value is outside the representable range of the target `type`. For example, `300 as u8` will abort since `u8` can only represent values 0-255.
71+
6272
### `needless_bool`
6373

6474
Checks for patterns of the form (where `x` is any arbitrary boolean expression):

0 commit comments

Comments
 (0)