diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-03-17 21:14:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-18 05:14:14 +0800 |
commit | d837a46ebd1c3a01c3493660f01cbccee68e1aa4 (patch) | |
tree | 1ceb3937af69e1265bb0b8a1e4309b51b705e9ab | |
parent | d4303b62cc2d4010baf276b7dc365fc580c7c630 (diff) | |
download | tracifyjs-d837a46ebd1c3a01c3493660f01cbccee68e1aa4.tar.gz tracifyjs-d837a46ebd1c3a01c3493660f01cbccee68e1aa4.zip |
fix corner case in `reduce_vars` (#4796)
-rw-r--r-- | lib/compress.js | 1 | ||||
-rw-r--r-- | test/compress/spreads.js | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index f8b9c8c3..0d4f7abc 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -624,6 +624,7 @@ merge(Compressor.prototype, { if (parent instanceof AST_Binary) return lazy_op[parent.operator]; if (parent instanceof AST_Conditional) return parent.condition !== node; if (parent instanceof AST_Sequence) return parent.tail_node() === node; + if (parent instanceof AST_Spread) return true; } function mark_escaped(tw, d, scope, node, value, level, depth) { diff --git a/test/compress/spreads.js b/test/compress/spreads.js index f8c0d592..02bb3f0e 100644 --- a/test/compress/spreads.js +++ b/test/compress/spreads.js @@ -294,6 +294,31 @@ reduce_vars_2: { node_version: ">=6" } +reduce_vars_3: { + options = { + reduce_funcs: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function f() {} + function g() { + return (a => a)(...[ f ]); + } + console.log(g() === g() ? "PASS" : "FAIL"); + } + expect: { + function f() {} + function g() { + return (a => a)(...[ f ]); + } + console.log(g() === g() ? "PASS" : "FAIL"); + } + expect_stdout: "PASS" + node_version: ">=6" +} + convert_setter: { options = { objects: true, |