fix(minifier): RemoveDeadCode should visit nested expression (#4268)

This commit is contained in:
underfin 2024-07-15 19:37:12 +08:00 committed by GitHub
parent 8fad7dbac3
commit f144082a60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View file

@ -26,6 +26,7 @@ impl<'a> VisitMut<'a> for RemoveDeadCode<'a> {
fn visit_expression(&mut self, expr: &mut Expression<'a>) {
self.fold_conditional_expression(expr);
self.fold_logical_expression(expr);
walk_mut::walk_expression(self, expr);
}
}

View file

@ -62,6 +62,12 @@ fn dce_if_statement() {
",
"{foo; return }",
);
// nested expression
test(
"const a = { fn: function() { if (true) { foo; } } }",
"const a = { fn: function() { { foo; } } }",
);
}
#[test]