diff options
author | Mihai Bazon <mihai.bazon@gmail.com> | 2015-01-12 18:18:55 +0200 |
---|---|---|
committer | Mihai Bazon <mihai.bazon@gmail.com> | 2015-01-12 18:18:55 +0200 |
commit | 189dbf02b6f0c1abc0c10f092d72f7ffcc58a48f (patch) | |
tree | 8879a10566f02177db66450ffa72d52d7639ff72 | |
parent | a10f6a96d724319f9bb582dab42392b4ef05a0e0 (diff) | |
parent | 42ecd42ac00881f7d540cb08969ce7e2721e30d5 (diff) | |
download | tracifyjs-189dbf02b6f0c1abc0c10f092d72f7ffcc58a48f.tar.gz tracifyjs-189dbf02b6f0c1abc0c10f092d72f7ffcc58a48f.zip |
Merge pull request #612 from rvanvelzen/issue-611
Replace the correct node when replacing in `void` sequences
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/issue-611.js | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index 1f1d4b50..72e4d92d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1937,7 +1937,7 @@ merge(Compressor.prototype, { if (self.cdr instanceof AST_UnaryPrefix && self.cdr.operator == "void" && !self.cdr.expression.has_side_effects(compressor)) { - self.cdr.operator = self.car; + self.cdr.expression = self.car; return self.cdr; } if (self.cdr instanceof AST_Undefined) { diff --git a/test/compress/issue-611.js b/test/compress/issue-611.js new file mode 100644 index 00000000..6f2c65d2 --- /dev/null +++ b/test/compress/issue-611.js @@ -0,0 +1,21 @@ +issue_611: { + options = { + sequences: true, + side_effects: true + }; + input: { + define(function() { + function fn() {} + if (fn()) { + fn(); + return void 0; + } + }); + } + expect: { + define(function() { + function fn(){} + if (fn()) return void fn(); + }); + } +} |