Skip to content

Commit

Permalink
fix is_number() on += (#1714)
Browse files Browse the repository at this point in the history
fixes #1710
  • Loading branch information
alexlamsl authored Mar 28, 2017
1 parent fb177a6 commit f71f490
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -1167,9 +1167,9 @@ merge(Compressor.prototype, {
&& this.left.is_number(compressor)
&& this.right.is_number(compressor);
});
var assign = makePredicate("-= *= /= %= &= |= ^= <<= >>= >>>=");
def(AST_Assign, function(compressor){
return assign(this.operator) || this.right.is_number(compressor);
return binary(this.operator.slice(0, -1))
|| this.operator == "=" && this.right.is_number(compressor);
});
def(AST_Seq, function(compressor){
return this.cdr.is_number(compressor);
Expand Down
15 changes: 15 additions & 0 deletions test/compress/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,18 @@ evaluate_4: {
);
}
}

issue_1710: {
options = {
evaluate: true,
}
input: {
var x = {};
console.log((x += 1) + -x);
}
expect: {
var x = {};
console.log((x += 1) + -x);
}
expect_stdout: true
}

0 comments on commit f71f490

Please sign in to comment.