Skip to content

Commit

Permalink
avoid inlining identityFn(...expandedArgs). closes #1226
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiosantoscode committed Jul 19, 2022
1 parent 0136e8a commit ea5dcc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress/inline.js
Expand Up @@ -335,6 +335,7 @@ export function inline_into_call(self, fn, compressor) {
fn.argnames.length === 1
&& (fn.argnames[0] instanceof AST_SymbolFunarg)
&& self.args.length < 2
&& !(self.args[0] instanceof AST_Expansion)
&& returned instanceof AST_SymbolRef
&& returned.name === fn.argnames[0].name
) {
Expand Down
15 changes: 15 additions & 0 deletions test/compress/identity.js
Expand Up @@ -249,3 +249,18 @@ inline_identity_dont_lose_this_when_arg: {
}
}

inline_trivial_fns_unless_arg_is_expansion: {
options = {
toplevel: true,
inline: true,
}
input: {
function n (n) {
return n;
}
(function(...o) {
const c=n(...o);console.log(c)
})("PASS");
}
expect_stdout: "PASS"
}

0 comments on commit ea5dcc3

Please sign in to comment.