Skip to content

Commit

Permalink
Merge branch 'master' into harmony-v2.8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Mar 5, 2017
2 parents 33a26d4 + a5d62a3 commit aa60549
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
10 changes: 7 additions & 3 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -2970,7 +2970,7 @@ merge(Compressor.prototype, {
if (self.car instanceof AST_Assign
&& !self.car.left.has_side_effects(compressor)) {
left = self.car.left;
} else if (self.car instanceof AST_UnaryPostfix
} else if (self.car instanceof AST_Unary
&& (self.car.operator == "++" || self.car.operator == "--")) {
left = self.car.expression;
}
Expand All @@ -2979,11 +2979,15 @@ merge(Compressor.prototype, {
var cdr = self.cdr;
while (true) {
if (cdr.equivalent_to(left)) {
var car = self.car instanceof AST_UnaryPostfix ? make_node(AST_UnaryPrefix, self.car, {
operator: self.car.operator,
expression: left
}) : self.car;
if (parent) {
parent[field] = self.car;
parent[field] = car;
return self.cdr;
}
return self.car;
return car;
}
if (cdr instanceof AST_Binary && !(cdr instanceof AST_Assign)) {
field = cdr.left.is_constant() ? "right" : "left";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"homepage": "http://lisperator.net/uglifyjs",
"author": "Mihai Bazon <[email protected]> (http://lisperator.net/)",
"license": "BSD-2-Clause",
"version": "2.8.6",
"version": "2.8.7",
"engines": {
"node": ">=0.8.0"
},
Expand Down
16 changes: 15 additions & 1 deletion test/compress/issue-368.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ collapse: {
var a;
a = b(a / 2);
if (a < 0) {
a++;
++c;
return c / 2;
}
}
function f4(c) {
var a;
a = b(a / 2);
if (a < 0) {
a++;
c++;
return c / 2;
}
Expand All @@ -35,7 +45,11 @@ collapse: {
}
function f3(c) {
var a;
if ((a = b(a / 2)) < 0) return c++ / 2;
if ((a = b(a / 2)) < 0) return a++, ++c / 2;
}
function f4(c) {
var a;
if ((a = b(a / 2)) < 0) return a++, ++c / 2;
}
}
}

0 comments on commit aa60549

Please sign in to comment.