@@ -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
0 commit comments