Skip to content

Commit

Permalink
fix corner case in if_return (#3601)
Browse files Browse the repository at this point in the history
fixes #3600
  • Loading branch information
alexlamsl committed Nov 19, 2019
1 parent 67278e7 commit d959e0b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/compress.js
Expand Up @@ -1805,6 +1805,7 @@ merge(Compressor.prototype, {
stat.alternative = make_node(AST_BlockStatement, stat, {
body: body
});
statements[i] = stat;
statements[i] = stat.transform(compressor);
continue;
}
Expand All @@ -1817,6 +1818,7 @@ merge(Compressor.prototype, {
stat.condition = negated;
statements[j] = stat.body;
stat.body = next;
statements[i] = stat;
statements[i] = stat.transform(compressor);
continue;
}
Expand All @@ -1834,6 +1836,7 @@ merge(Compressor.prototype, {
stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
body: body
});
statements[i] = stat;
statements[i] = stat.transform(compressor);
continue;
}
Expand Down
29 changes: 29 additions & 0 deletions test/compress/if_return.js
Expand Up @@ -544,3 +544,32 @@ if_body_return_3: {
"PASS",
]
}

issue_3600: {
options = {
if_return: true,
inline: true,
side_effects: true,
unused: true,
}
input: {
var c = 0;
(function() {
if ([ ][c++]); else return;
return void function() {
var b = --b, a = c = 42;
return c;
}();
})();
console.log(c);
}
expect: {
var c = 0;
(function() {
if ([][c++]) b = --b, c = 42;
var b;
})();
console.log(c);
}
expect_stdout: "1"
}

0 comments on commit d959e0b

Please sign in to comment.