enhance comparisons (#4062)
This commit is contained in:
@@ -7112,7 +7112,7 @@ merge(Compressor.prototype, {
|
||||
&& self.right instanceof AST_SymbolRef
|
||||
&& self.left.definition() === self.right.definition()
|
||||
&& is_object(self.left)) {
|
||||
return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
|
||||
return make_node(self.operator[0] == "=" ? AST_True : AST_False, self).optimize(compressor);
|
||||
}
|
||||
break;
|
||||
case "&&":
|
||||
|
||||
@@ -123,6 +123,29 @@ self_comparison_3: {
|
||||
]
|
||||
}
|
||||
|
||||
self_comparison_4: {
|
||||
options = {
|
||||
booleans: true,
|
||||
comparisons: true,
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var o = {};
|
||||
console.log(o == o, o != o);
|
||||
console.log(o === o, o !== o);
|
||||
}
|
||||
expect: {
|
||||
console.log(!0, !1);
|
||||
console.log(!0, !1);
|
||||
}
|
||||
expect_stdout: [
|
||||
"true false",
|
||||
"true false",
|
||||
]
|
||||
}
|
||||
|
||||
issue_2857_1: {
|
||||
options = {
|
||||
comparisons: true,
|
||||
|
||||
Reference in New Issue
Block a user