@@ -3689,20 +3689,25 @@ merge(Compressor.prototype, {
|
|||||||
(function(def) {
|
(function(def) {
|
||||||
def(AST_Node, return_false);
|
def(AST_Node, return_false);
|
||||||
def(AST_Array, return_true);
|
def(AST_Array, return_true);
|
||||||
def(AST_Assign, function(compressor) {
|
function is_binary_defined(compressor, op, node) {
|
||||||
return this.operator != "=" || this.right.is_defined(compressor);
|
switch (op) {
|
||||||
});
|
|
||||||
def(AST_Binary, function(compressor) {
|
|
||||||
switch (this.operator) {
|
|
||||||
case "&&":
|
case "&&":
|
||||||
return this.left.is_defined(compressor) && this.right.is_defined(compressor);
|
return node.left.is_defined(compressor) && node.right.is_defined(compressor);
|
||||||
case "||":
|
case "||":
|
||||||
return this.left.is_truthy() || this.right.is_defined(compressor);
|
return node.left.is_truthy() || node.right.is_defined(compressor);
|
||||||
case "??":
|
case "??":
|
||||||
return this.left.is_defined(compressor) || this.right.is_defined(compressor);
|
return node.left.is_defined(compressor) || node.right.is_defined(compressor);
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
def(AST_Assign, function(compressor) {
|
||||||
|
var op = this.operator;
|
||||||
|
if (op == "=") return this.right.is_defined(compressor);
|
||||||
|
return is_binary_defined(compressor, op.slice(0, -1), this);
|
||||||
|
});
|
||||||
|
def(AST_Binary, function(compressor) {
|
||||||
|
return is_binary_defined(compressor, this.operator, this);
|
||||||
});
|
});
|
||||||
def(AST_Conditional, function(compressor) {
|
def(AST_Conditional, function(compressor) {
|
||||||
return this.consequent.is_defined(compressor) && this.alternative.is_defined(compressor);
|
return this.consequent.is_defined(compressor) && this.alternative.is_defined(compressor);
|
||||||
|
|||||||
@@ -589,3 +589,17 @@ issue_4815_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=15"
|
node_version: ">=15"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4819: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(void 0 === ([].p &&= 42));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(void 0 === ([].p &&= 42));
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
|
node_version: ">=15"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user