mirror of
https://github.com/swc-project/swc.git
synced 2024-12-26 15:12:08 +03:00
fix(es/compat): Handle a nullish coalescing in a switch case (#6363)
This commit is contained in:
parent
0f09f82db3
commit
2de45fb0f7
@ -74,8 +74,10 @@ impl VisitMut for NullishCoalescing {
|
||||
|
||||
/// Prevents #1123
|
||||
fn visit_mut_switch_case(&mut self, s: &mut SwitchCase) {
|
||||
// Prevents #6328
|
||||
s.test.visit_mut_with(self);
|
||||
let old_vars = self.vars.take();
|
||||
s.visit_mut_children_with(self);
|
||||
s.cons.visit_mut_with(self);
|
||||
self.vars = old_vars;
|
||||
}
|
||||
|
||||
|
@ -166,3 +166,14 @@ function foo(opts) {
|
||||
}
|
||||
"#
|
||||
);
|
||||
|
||||
test!(
|
||||
syntax(),
|
||||
|_| tr(Default::default()),
|
||||
issue_6328,
|
||||
"switch ( 0 ) { case 0 ?? 0 : }",
|
||||
r#"
|
||||
var ref;
|
||||
switch ( 0 ) { case (ref = 0) !== null && ref !== void 0 ? ref : 0: }
|
||||
"#
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user