File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -585,6 +585,9 @@ fn test() {
585585 "reportUnusedFallthroughComment" : false
586586 } ] ) ) ,
587587 ) ,
588+ // Issue #6417: switch with logical operators should work correctly with break
589+ ( "switch(true) { case x === 1 || x === 2: a(); break; case x === 3: b(); }" , None ) ,
590+ ( "switch(true) { case x === 1 && y: a(); break; case x === 3: b(); }" , None ) ,
588591 ] ;
589592
590593 let fail = vec ! [
@@ -648,6 +651,9 @@ fn test() {
648651 "reportUnusedFallthroughComment" : true
649652 } ] ) ) ,
650653 ) ,
654+ // Issue #6417: switch with logical operators should detect fallthrough
655+ ( "switch(true) { case x === 1 || x === 2: a(); case x === 3: b(); }" , None ) ,
656+ ( "switch(true) { case x === 1 && y: a(); case x === 3: b(); }" , None ) ,
651657 // TODO: it should fail but doesn't, we ignore conditional discriminants for now.
652658 // ("switch (a === b ? c : d) { case 1: ; case 2: ; case 3: ; }", None)
653659 ] ;
Original file line number Diff line number Diff line change @@ -174,3 +174,15 @@ source: crates/oxc_linter/src/tester.rs
174174 1 │ switch (foo ) { case 0 : a (); break ; /* falls through */ case 1 : b (); }
175175 · ─────────────────────
176176 ╰────
177+
178+ ⚠ eslint (no - fallthrough ): Expected a ' break' statement before ' case' .
179+ ╭─[no_fallthrough .tsx :1 :46 ]
180+ 1 │ switch (true ) { case x === 1 || x === 2 : a (); case x === 3 : b (); }
181+ · ──────────────────
182+ ╰────
183+
184+ ⚠ eslint (no - fallthrough ): Expected a ' break' statement before ' case' .
185+ ╭─[no_fallthrough .tsx :1 :40 ]
186+ 1 │ switch (true ) { case x === 1 && y : a (); case x === 3 : b (); }
187+ · ──────────────────
188+ ╰────
You can’t perform that action at this time.
0 commit comments