diff --git a/lib/compress/index.js b/lib/compress/index.js index 97a9b11a6..0a69bd5e2 100644 --- a/lib/compress/index.js +++ b/lib/compress/index.js @@ -5603,15 +5603,31 @@ def_optimize(AST_Call, function(self, compressor) { if (has_flag(arg, UNUSED)) continue; if (!safe_to_inject || block_scoped.has(arg.name) - || identifier_atom.has(arg.name) - || scope.conflicting_def(arg.name)) { + || identifier_atom.has(arg.name)) { return false; } + if (scope.conflicting_def(arg.name)) { + rename_arg(arg); + } if (in_loop) in_loop.push(arg.definition()); } return true; } + function rename_arg(arg) { + const newArgName = fn.create_symbol(AST_SymbolFunarg, { + source: fn, + scope: fn, + tentative_name: "argument_" + fn.argnames.length, + }); + walk(fn, (node) => { + if (node instanceof AST_SymbolRef && node.thedef.name === arg.name) { + node.thedef.name = newArgName; + } + return node; + }); + } + function can_inject_vars(block_scoped, safe_to_inject) { var len = fn.body.length; for (var i = 0; i < len; i++) { diff --git a/test/compress/toplevel-pure-method.js b/test/compress/toplevel-pure-method.js index cf805c9fc..cf9dd41e8 100644 --- a/test/compress/toplevel-pure-method.js +++ b/test/compress/toplevel-pure-method.js @@ -45,7 +45,6 @@ inline_different_name: { } } -// TODO: rename_and_inline: { options = { toplevel: true,