mirror of
https://github.com/swc-project/swc.git
synced 2024-10-04 20:28:43 +03:00
fix(es/minifier): Preserve function length (#9389)
**Related issue:** - Closes https://github.com/swc-project/swc/issues/9356
This commit is contained in:
parent
7899f5fc33
commit
679682ce36
@ -11345,3 +11345,8 @@ fn issue_9184_2() {
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_9356() {
|
||||
run_default_exec_test("console.log((function ({ } = 42) { }).length)");
|
||||
}
|
||||
|
@ -314,15 +314,6 @@ impl VisitMut for Remover {
|
||||
*p = *assign.left.take();
|
||||
}
|
||||
|
||||
Pat::Assign(assign)
|
||||
if match *assign.left {
|
||||
Pat::Object(ref o) => o.props.is_empty(),
|
||||
_ => false,
|
||||
} && assign.right.is_number() =>
|
||||
{
|
||||
*p = *assign.left.take();
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -1452,16 +1452,6 @@ fn test_empty_key_in_object_pattern_removed() {
|
||||
test_same("const {[foo()]: {}} = {};");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_empty_key_in_object_pattern_with_default_value_maybe_removed() {
|
||||
test("const {f: {} = 0} = {};", "");
|
||||
// In theory the following case could be reduced to `foo()`, but that gets more
|
||||
// complicated to implement for object patterns with multiple keys with side
|
||||
// effects. Instead the pass backs off for any default with a possible side
|
||||
// effect
|
||||
test_same("const {f: {} = foo()} = {};");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_empty_key_in_object_pattern_not_removed_with_object_rest() {
|
||||
test_same("const {f: {}, ...g} = foo()");
|
||||
|
Loading…
Reference in New Issue
Block a user