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

Commit 242edb3

Browse files
authored
Add simpler_bool_expression documentation to linter page (#974)
add `simpler_bool_expression` doc to linter page
1 parent 8cdd03b commit 242edb3

File tree

1 file changed

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

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,27 @@ Checks for patterns where a variable or a field of a struct is assigned to itsel
101101
- `x = x;`
102102
- `a.x = a.x;`
103103

104+
### `simpler_bool_expression`
105+
106+
Checks for boolean patterns that can be simplified through different boolean algebra laws. Examples include:
107+
- Absorption law:
108+
- `a && b || a` can be simplified to `a`
109+
- `a || a && b` can be simplified to `a`
110+
- Idempotence:
111+
- `a && a` can be simplified to `a`
112+
- `a || a` can be simplified to `a`
113+
- Contradiction
114+
- `a && !a` can be simplified to `false`
115+
- `!a && a` can be simplified to `false`
116+
- Tautology:
117+
- `a || !a` can be simplified to `true`
118+
- `!a || a` can be simplified to `true`
119+
- Distributive law:
120+
- `(a && b) || (a && c)` can be simplified to `a && (b || c)`
121+
- `(a || b) && (a || c)` can be simplified to `a || (b && c)`
122+
123+
Where `a`, `b` and `c` can either be simple or composed expressions.
124+
104125
### `simpler_numeric_expression`
105126

106127
Checks for various patterns where a simpler numeric expression can be used instead. In all these cases, the code must already type check, and `x` can be any numeric expression.

0 commit comments

Comments
 (0)