Skip to content

Commit

Permalink
fix(es/minifier): Abort fn inliner if there's a spread arg (#8809)
Browse files Browse the repository at this point in the history
**Description:**


**Related issue:**

 - Closes #8806
  • Loading branch information
kdy1 authored Apr 4, 2024
1 parent d1eb7b8 commit 730ded2
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/swc_ecma_minifier/src/compress/optimize/iife.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,10 @@ impl Optimizer<'_> {
return None;
}

if args.iter().any(|arg| arg.spread.is_some()) {
return None;
}

if self.vars.inline_with_multi_replacer(body) {
self.changed = true;
}
Expand Down
48 changes: 48 additions & 0 deletions crates/swc_ecma_minifier/tests/fixture/issues/8806/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"defaults": true,
"arguments": false,
"arrows": true,
"booleans": true,
"booleans_as_integers": false,
"collapse_vars": true,
"comparisons": true,
"computed_props": true,
"conditionals": true,
"dead_code": true,
"directives": true,
"drop_console": false,
"drop_debugger": true,
"evaluate": true,
"expression": false,
"hoist_funs": false,
"hoist_props": true,
"hoist_vars": false,
"if_return": true,
"join_vars": true,
"keep_classnames": false,
"keep_fargs": true,
"keep_fnames": false,
"keep_infinity": false,
"loops": true,
"negate_iife": true,
"properties": true,
"reduce_funcs": false,
"reduce_vars": false,
"side_effects": true,
"switches": true,
"typeofs": true,
"unsafe": false,
"unsafe_arrows": false,
"unsafe_comps": false,
"unsafe_Function": false,
"unsafe_math": false,
"unsafe_symbols": false,
"unsafe_methods": false,
"unsafe_proto": false,
"unsafe_regexp": false,
"unsafe_undefined": false,
"unused": true,
"const_to_let": true,
"pristine_globals": true,
"passes": 2
}
8 changes: 8 additions & 0 deletions crates/swc_ecma_minifier/tests/fixture/issues/8806/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

function logTheNine() {
((theThree, theNine) => {
console.log(theNine)
})(...[3, 9]);
}

logTheNine();
9 changes: 9 additions & 0 deletions crates/swc_ecma_minifier/tests/fixture/issues/8806/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function logTheNine() {
((theThree, theNine)=>{
console.log(theNine);
})(...[
3,
9
]);
}
logTheNine();

0 comments on commit 730ded2

Please sign in to comment.