Merge pull request #612 from rvanvelzen/issue-611

Replace the correct node when replacing in `void` sequences
This commit is contained in:
Mihai Bazon 2015-01-12 18:18:55 +02:00
commit 189dbf02b6
2 changed files with 22 additions and 1 deletions

View File

@ -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) {

View File

@ -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();
});
}
}