Skip to content

Commit c253f49

Browse files
committed
tweak comments
1 parent 78f878b commit c253f49

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

turbopack/crates/turbopack-ecmascript/src/analyzer/side_effects.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
//! - Function calls (unless marked with `/*#__PURE__*/` or otherwise known to be pure)
1010
//! - Constructor calls (unless marked with `/*#__PURE__*/`or otherwise known to be pure )
1111
//! - Assignments to variables or properties
12-
//! - TODO: Unless the variable is defined in the same scope.
1312
//! - Property mutations
14-
//! - TODO: Unless the object being mutated is defined in the same scope
1513
//! - Update expressions (`++`, `--`)
1614
//! - Delete expressions
1715
//! - Async operations (await)
@@ -117,17 +115,29 @@
117115
//!
118116
//! **Important Edge Cases**:
119117
//!
120-
//! 1. **Reassignment invalidates purity**: ```javascript const config = {}; // pure local
118+
//! 1. **Reassignment invalidates purity**:
119+
//! ```javascript
120+
//! const config = {}; // pure local
121121
//! config.a = 1; // OK, still pure config = external.obj; // config is now impure
122-
//! (tainted) config.b = 2; // Side effect! config is tainted ```
122+
//! (tainted) config.b = 2; // Side effect! config is tainted
123+
//! ```
123124
//!
124-
//! 2. **Property access doesn't track deeply**: ```javascript const obj = { nested: {} }; const ref
125-
//! = obj.nested; // ref escapes, obj.nested is now tainted ref.prop = 1; // Side
126-
//! effect! ref escaped ``` Initially, only track first-level escaping. Deep tracking is complex.
125+
//! 2. **Property access doesn't track deeply**:
126+
//! ```javascript
127+
//! const obj = { nested: {} };
128+
//! const ref = obj.nested; // ref escapes, obj.nested is now tainted
129+
//! ref.prop = 1; // Side effect! ref escaped
130+
//! ```
131+
//! Initially, only track first-level escaping. Deep tracking is complex.
127132
//!
128-
//! 3. **Function boundaries**: ```javascript const config = {}; function setup() { config.x = 1; //
129-
//! Still OK - function not called at module eval time } const arr = [config]; // config escapes
130-
//! into array ```
133+
//! 3. **Function boundaries**:
134+
//! ```javascript
135+
//! const config = {};
136+
//! function setup() {
137+
//! config.x = 1; // Still OK - function not called at module eval time
138+
//! }
139+
//! const arr = [config]; // config escapes into array
140+
//! ```
131141
//!
132142
//! **Integration with Existing Analyzer**:
133143
//!

0 commit comments

Comments
 (0)