File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
crates/oxc_minifier/src/peephole Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,12 @@ impl<'a> PeepholeOptimizations {
7171 // "while (x) { y(); continue; }" => "while (x) { y(); }"
7272 Statement :: ContinueStatement ( s) if s. label . is_none ( ) => {
7373 let mut changed = false ;
74- if let Some ( Ancestor :: ForStatementBody ( _) ) = ctx. ancestors ( ) . nth ( 1 ) {
74+ if let Some (
75+ Ancestor :: ForStatementBody ( _)
76+ | Ancestor :: ForInStatementBody ( _)
77+ | Ancestor :: ForOfStatementBody ( _) ,
78+ ) = ctx. ancestors ( ) . nth ( 1 )
79+ {
7580 stmts. pop ( ) ;
7681 changed = true ;
7782 }
@@ -1815,5 +1820,9 @@ mod test {
18151820 test ( "for( a of b ){ if(c) { continue; } d() }" , "for ( a of b ) c || d();" ) ;
18161821 test ( "for( a in b ){ if(c) { continue; } d() }" , "for ( a in b ) c || d();" ) ;
18171822 test ( "for( ; ; ){ if(c) { continue; } d() }" , "for ( ; ; ) c || d();" ) ;
1823+
1824+ test ( "for( a of b ){ c(); continue; }" , "for ( a of b ) c();" ) ;
1825+ test ( "for( a in b ){ c(); continue; }" , "for ( a in b ) c();" ) ;
1826+ test ( "for( ; ; ){ c(); continue; }" , "for ( ; ; ) c();" ) ;
18181827 }
18191828}
You can’t perform that action at this time.
0 commit comments