Skip to content

Commit

Permalink
fix corner case in reduce_vars (#4796)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Mar 17, 2021
1 parent d4303b6 commit d837a46
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -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) {
Expand Down
25 changes: 25 additions & 0 deletions test/compress/spreads.js
Expand Up @@ -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,
Expand Down

0 comments on commit d837a46

Please sign in to comment.