|
9 | 9 | //! - Function calls (unless marked with `/*#__PURE__*/` or otherwise known to be pure) |
10 | 10 | //! - Constructor calls (unless marked with `/*#__PURE__*/`or otherwise known to be pure ) |
11 | 11 | //! - Assignments to variables or properties |
12 | | -//! - TODO: Unless the variable is defined in the same scope. |
13 | 12 | //! - Property mutations |
14 | | -//! - TODO: Unless the object being mutated is defined in the same scope |
15 | 13 | //! - Update expressions (`++`, `--`) |
16 | 14 | //! - Delete expressions |
17 | 15 | //! - Async operations (await) |
|
117 | 115 | //! |
118 | 116 | //! **Important Edge Cases**: |
119 | 117 | //! |
120 | | -//! 1. **Reassignment invalidates purity**: ```javascript const config = {}; // pure local |
| 118 | +//! 1. **Reassignment invalidates purity**: |
| 119 | +//! ```javascript |
| 120 | +//! const config = {}; // pure local |
121 | 121 | //! 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 | +//! ``` |
123 | 124 | //! |
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. |
127 | 132 | //! |
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 | +//! ``` |
131 | 141 | //! |
132 | 142 | //! **Integration with Existing Analyzer**: |
133 | 143 | //! |
|
0 commit comments