var right = this.right.drop_side_effect_free(compressor, first_in_statement);
if (!right) return this.left.drop_side_effect_free(compressor, first_in_statement);
if (lazy_op[this.operator]) {
- if (right === this.right) return this;
- var node = this.clone();
- node.right = right.drop_side_effect_free(compressor);
- return node;
+ var node;
+ if (right === this.right) {
+ node = this;
+ } else {
+ node = this.clone();
+ node.right = right.drop_side_effect_free(compressor);
+ }
+ return (first_in_statement ? best_of_statement : best_of_expression)(node, make_node(AST_Binary, this, {
+ operator: node.operator == "&&" ? "||" : "&&",
+ left: node.left.negate(compressor, first_in_statement),
+ right: node.right
+ }));
} else {
var left = this.left.drop_side_effect_free(compressor, first_in_statement);
if (!left) return right;
-
issue_1639_1: {
options = {
booleans: true,
}
input: {
var a = 100, b = 10;
-
var L1 = 5;
while (--L1 > 0) {
if ((--b), false) {
}
}
}
-
console.log(a, b);
}
expect: {
if (--b, 0) var ignore = 0;
console.log(a, b);
}
- expect_stdout: true
+ expect_stdout: "100 6"
}
issue_1639_2: {
}
input: {
var a = 100, b = 10;
-
function f19() {
if (++a, false)
if (a)
if (++a);
}
f19();
-
console.log(a, b);
}
expect: {
var a = 100, b = 10;
function f19() {
- ++a, 0;
+ ++a, 1;
}
f19(),
console.log(a, b);
}
- expect_stdout: true
+ expect_stdout: "101 10"
}
issue_1639_3: {
a++,
console.log(a, b);
}
- expect_stdout: true
+ expect_stdout: "101 10"
}
}
expect: {
function f(a, b) {
- !(b += a) && ((b = a) || (b -= a, b ^= a)),
+ (b += a) || (b = a) || (b -= a, b ^= a),
a--;
}
}