From ea5dcc3e712cb3805160d69ba37d20f48891cca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Santos?= Date: Tue, 19 Jul 2022 20:24:02 +0100 Subject: [PATCH] avoid inlining `identityFn(...expandedArgs)`. closes #1226 --- lib/compress/inline.js | 1 + test/compress/identity.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/compress/inline.js b/lib/compress/inline.js index fea4be2a4..eec4c5c91 100644 --- a/lib/compress/inline.js +++ b/lib/compress/inline.js @@ -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 ) { diff --git a/test/compress/identity.js b/test/compress/identity.js index 49f2b1045..3d00f1164 100644 --- a/test/compress/identity.js +++ b/test/compress/identity.js @@ -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" +}