diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-11-19 15:45:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-19 15:45:20 +0800 |
commit | d959e0b86ff36156be2e7ec2cffdd57f1e30e8dd (patch) | |
tree | ad73f48e1a8530a6db6e71a802e693c8cc970655 | |
parent | 67278e76c8777d57d40b42151be28b527e692ba2 (diff) | |
download | tracifyjs-d959e0b86ff36156be2e7ec2cffdd57f1e30e8dd.tar.gz tracifyjs-d959e0b86ff36156be2e7ec2cffdd57f1e30e8dd.zip |
fix corner case in `if_return` (#3601)
fixes #3600
-rw-r--r-- | lib/compress.js | 3 | ||||
-rw-r--r-- | test/compress/if_return.js | 29 |
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 8c1ed5b3..4ce283da 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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; } @@ -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; } @@ -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; } diff --git a/test/compress/if_return.js b/test/compress/if_return.js index 857406d4..82df1cea 100644 --- a/test/compress/if_return.js +++ b/test/compress/if_return.js @@ -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" +} |