Skip to content

Commit

Permalink
fix corner case in conditionals (#4777)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Mar 15, 2021
1 parent 4fb54b0 commit 2619bff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -11044,6 +11044,7 @@ merge(Compressor.prototype, {
if (len != b.length) return -2;
for (var i = 0; i < len; i++) {
if (!a[i].equivalent_to(b[i])) {
if (a[i] instanceof AST_Spread !== b[i] instanceof AST_Spread) return -3;
for (var j = i + 1; j < len; j++) {
if (!a[j].equivalent_to(b[j])) return -2;
}
Expand Down
24 changes: 23 additions & 1 deletion test/compress/spreads.js
Expand Up @@ -85,7 +85,7 @@ collapse_vars_4: {
node_version: ">=6"
}

conditionals_farg: {
conditionals_farg_1: {
options = {
conditionals: true,
}
Expand All @@ -107,6 +107,28 @@ conditionals_farg: {
node_version: ">=6"
}

conditionals_farg_2: {
options = {
conditionals: true,
pure_getters: "strict",
reduce_vars: true,
}
input: {
var log = console.log;
(function(a) {
return a.length ? log(...a) : log("FAIL");
})([ "PASS" ]);
}
expect: {
var log = console.log;
(function(a) {
return a.length ? log(...a) : log("FAIL");
})([ "PASS" ]);
}
expect_stdout: "PASS"
node_version: ">=6"
}

dont_inline: {
options = {
inline: true,
Expand Down

0 comments on commit 2619bff

Please sign in to comment.