diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-12-29 10:58:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-29 18:58:29 +0800 |
commit | 10a71c182bc4b992c91863fe0eb50a1afdae8a6f (patch) | |
tree | 4c87d141c5a66a32eeb53875e74fa92c958295e8 /lib/compress.js | |
parent | ddc0ed7072ed460f0121a700a6e7fde8fe28400a (diff) | |
download | tracifyjs-10a71c182bc4b992c91863fe0eb50a1afdae8a6f.tar.gz tracifyjs-10a71c182bc4b992c91863fe0eb50a1afdae8a6f.zip |
fix corner case in `arguments` (#4477)
fixes #4476
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/compress.js b/lib/compress.js index 103f47f1..0369b63d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -10173,22 +10173,26 @@ merge(Compressor.prototype, { var argname = fn.argnames[index]; if (def.deleted && def.deleted[index]) { argname = null; - } else if (argname && !(argname instanceof AST_SymbolFunarg)) { - argname = null; - } else if (argname && (compressor.has_directive("use strict") - || fn.name - || !(fn_parent instanceof AST_Call && index < fn_parent.args.length) - || !all(fn.argnames, function(argname) { - return argname instanceof AST_SymbolFunarg; - }))) { - var arg_def = argname.definition(); - if (!compressor.option("reduce_vars") - || def.reassigned - || arg_def.assignments - || arg_def.orig.length > 1) { + } else if (argname) { + var arg_def; + if (!(argname instanceof AST_SymbolFunarg)) { argname = null; + } else if (expr.scope.find_variable(argname.name) !== (arg_def = argname.definition())) { + argname = null; + } else if (compressor.has_directive("use strict") + || fn.name + || !(fn_parent instanceof AST_Call && index < fn_parent.args.length) + || !all(fn.argnames, function(argname) { + return argname instanceof AST_SymbolFunarg; + })) { + if (!compressor.option("reduce_vars") + || def.reassigned + || arg_def.assignments + || arg_def.orig.length > 1) { + argname = null; + } } - } else if (!argname && index < fn.argnames.length + 5 && compressor.drop_fargs(fn, fn_parent)) { + } else if (index < fn.argnames.length + 5 && compressor.drop_fargs(fn, fn_parent)) { while (index >= fn.argnames.length) { argname = fn.make_var(AST_SymbolFunarg, fn, "argument_" + fn.argnames.length); fn.argnames.push(argname); |