diff --git a/crates/swc_ecma_minifier/tests/exec.rs b/crates/swc_ecma_minifier/tests/exec.rs index 11f71aaca2b4..daf0d4021f79 100644 --- a/crates/swc_ecma_minifier/tests/exec.rs +++ b/crates/swc_ecma_minifier/tests/exec.rs @@ -11345,3 +11345,8 @@ fn issue_9184_2() { "#, ); } + +#[test] +fn issue_9356() { + run_default_exec_test("console.log((function ({ } = 42) { }).length)"); +} diff --git a/crates/swc_ecma_transforms_optimization/src/simplify/branch/mod.rs b/crates/swc_ecma_transforms_optimization/src/simplify/branch/mod.rs index 1ddeaf3c153f..4478b24dd713 100644 --- a/crates/swc_ecma_transforms_optimization/src/simplify/branch/mod.rs +++ b/crates/swc_ecma_transforms_optimization/src/simplify/branch/mod.rs @@ -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(); - } - _ => {} } } diff --git a/crates/swc_ecma_transforms_optimization/src/simplify/branch/tests.rs b/crates/swc_ecma_transforms_optimization/src/simplify/branch/tests.rs index a403e15a2d10..c05585ed7c00 100644 --- a/crates/swc_ecma_transforms_optimization/src/simplify/branch/tests.rs +++ b/crates/swc_ecma_transforms_optimization/src/simplify/branch/tests.rs @@ -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()");