diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-01-20 23:23:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-21 07:23:06 +0800 |
commit | c1e771a89a65751016bbafd56d710accf6d7bf21 (patch) | |
tree | 87d21dfd5ab41f0b70e5cf465dd463e26ec39f81 /lib/compress.js | |
parent | bc7a88baea6f81a77f4cde635b9f8c918ddede06 (diff) | |
download | tracifyjs-c1e771a89a65751016bbafd56d710accf6d7bf21.tar.gz tracifyjs-c1e771a89a65751016bbafd56d710accf6d7bf21.zip |
fix corner case in `rests` (#4576)
fixes #4575
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/compress.js b/lib/compress.js index 4710b69f..fc1bc118 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -7845,11 +7845,11 @@ merge(Compressor.prototype, { if (fn.rest) { if (!(is_iife && compressor.option("rests"))) return; var insert = fn.argnames.length; - for (var i = args.length; i < insert; i++) { - args[i] = make_node(AST_Undefined, call).optimize(compressor); - } - args[insert] = make_node(AST_Array, call, { elements: args.splice(insert) }); - fn.argnames.push(fn.rest); + args = args.slice(0, insert); + while (args.length < insert) args.push(make_node(AST_Undefined, call).optimize(compressor)); + args.push(make_node(AST_Array, call, { elements: call.args.slice(insert) })); + call.args = args; + fn.argnames = fn.argnames.concat(fn.rest); fn.rest = null; } var pos = 0, last = 0; |