mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(minifier): RemoveDeadCode should visit nested expression (#4268)
This commit is contained in:
parent
8fad7dbac3
commit
f144082a60
2 changed files with 7 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ impl<'a> VisitMut<'a> for RemoveDeadCode<'a> {
|
||||||
fn visit_expression(&mut self, expr: &mut Expression<'a>) {
|
fn visit_expression(&mut self, expr: &mut Expression<'a>) {
|
||||||
self.fold_conditional_expression(expr);
|
self.fold_conditional_expression(expr);
|
||||||
self.fold_logical_expression(expr);
|
self.fold_logical_expression(expr);
|
||||||
|
walk_mut::walk_expression(self, expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,12 @@ fn dce_if_statement() {
|
||||||
",
|
",
|
||||||
"{foo; return }",
|
"{foo; return }",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// nested expression
|
||||||
|
test(
|
||||||
|
"const a = { fn: function() { if (true) { foo; } } }",
|
||||||
|
"const a = { fn: function() { { foo; } } }",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue