Skip to content

Commit 8b346bd

Browse files
committed
tweak
1 parent 0031117 commit 8b346bd

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,11 +1037,11 @@ mod analyzer_state {
10371037
}
10381038

10391039
pub(super) fn is_this_bound(&self) -> bool {
1040-
*self.state.block_context_stack.iter().any(|b| {
1040+
self.state.block_context_stack.iter().any(|b| {
10411041
matches!(
10421042
b,
10431043
BlockContext::Function {
1044-
id,
1044+
id: _,
10451045
binds_this: true
10461046
}
10471047
)
@@ -2205,8 +2205,18 @@ impl VisitAstPath for Analyzer<'_> {
22052205
n: &'ast WhileStmt,
22062206
ast_path: &mut swc_core::ecma::visit::AstNodePath<'r>,
22072207
) {
2208+
// Enter control flow for everything (test and body both repeat in loop iterations)
22082209
self.enter_control_flow(|this| {
2209-
n.visit_children_with_ast_path(this, ast_path);
2210+
{
2211+
let mut ast_path =
2212+
ast_path.with_guard(AstParentNodeRef::WhileStmt(n, WhileStmtField::Test));
2213+
n.test.visit_with_ast_path(this, &mut ast_path);
2214+
}
2215+
{
2216+
let mut ast_path =
2217+
ast_path.with_guard(AstParentNodeRef::WhileStmt(n, WhileStmtField::Body));
2218+
n.body.visit_with_ast_path(this, &mut ast_path);
2219+
}
22102220
});
22112221
}
22122222

@@ -2215,8 +2225,18 @@ impl VisitAstPath for Analyzer<'_> {
22152225
n: &'ast DoWhileStmt,
22162226
ast_path: &mut swc_core::ecma::visit::AstNodePath<'r>,
22172227
) {
2228+
// Enter control flow for everything (body and test both are part of loop iterations)
22182229
self.enter_control_flow(|this| {
2219-
n.visit_children_with_ast_path(this, ast_path);
2230+
{
2231+
let mut ast_path =
2232+
ast_path.with_guard(AstParentNodeRef::DoWhileStmt(n, DoWhileStmtField::Body));
2233+
n.body.visit_with_ast_path(this, &mut ast_path);
2234+
}
2235+
{
2236+
let mut ast_path =
2237+
ast_path.with_guard(AstParentNodeRef::DoWhileStmt(n, DoWhileStmtField::Test));
2238+
n.test.visit_with_ast_path(this, &mut ast_path);
2239+
}
22202240
});
22212241
}
22222242

turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/react-dom-production/resolved-effects.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19796,7 +19796,7 @@ ${La}${a}`("SuspenseList")
1979619796
- *0* unreachable
1979719797
⚠️ This value might have side effects
1979819798

19799-
2604 -> 2606 conditional = (???*0* | ???*1*)
19799+
2604 -> 2607 conditional = (???*0* | ???*1*)
1980019800
- *0* arguments[0]
1980119801
⚠️ function calls are not analyzed yet
1980219802
- *1* ???*2*["return"]

0 commit comments

Comments
 (0)