fix corner case in pure_getters (#5617)
This commit is contained in:
@@ -4469,7 +4469,13 @@ Compressor.prototype.compress = function(node) {
|
|||||||
def(AST_Binary, function(compressor) {
|
def(AST_Binary, function(compressor) {
|
||||||
return lazy_op[this.operator] && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
|
return lazy_op[this.operator] && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
|
||||||
});
|
});
|
||||||
def(AST_Class, return_false);
|
def(AST_Class, function(compressor, force) {
|
||||||
|
return is_strict(compressor, force) && !all(this.properties, function(prop) {
|
||||||
|
if (prop.private) return true;
|
||||||
|
if (!prop.static) return true;
|
||||||
|
return !(prop instanceof AST_ClassGetter || prop instanceof AST_ClassSetter);
|
||||||
|
});
|
||||||
|
});
|
||||||
def(AST_Conditional, function(compressor) {
|
def(AST_Conditional, function(compressor) {
|
||||||
return this.consequent._dot_throw(compressor) || this.alternative._dot_throw(compressor);
|
return this.consequent._dot_throw(compressor) || this.alternative._dot_throw(compressor);
|
||||||
});
|
});
|
||||||
@@ -4484,7 +4490,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
def(AST_Null, return_true);
|
def(AST_Null, return_true);
|
||||||
def(AST_Object, function(compressor, force) {
|
def(AST_Object, function(compressor, force) {
|
||||||
return is_strict(compressor, force) && !all(this.properties, function(prop) {
|
return is_strict(compressor, force) && !all(this.properties, function(prop) {
|
||||||
if (!(prop instanceof AST_ObjectKeyVal)) return false;
|
if (prop instanceof AST_ObjectGetter || prop instanceof AST_ObjectSetter) return false;
|
||||||
return !(prop.key === "__proto__" && prop.value._dot_throw(compressor, force));
|
return !(prop.key === "__proto__" && prop.value._dot_throw(compressor, force));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -746,6 +746,56 @@ separate_name: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static_getter: {
|
||||||
|
options = {
|
||||||
|
pure_getters: "strict",
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
(class {
|
||||||
|
static get p() {
|
||||||
|
console.log("PASS");
|
||||||
|
};
|
||||||
|
}).p;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
(class {
|
||||||
|
static get p() {
|
||||||
|
console.log("PASS");
|
||||||
|
};
|
||||||
|
}).p;
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
static_setter: {
|
||||||
|
options = {
|
||||||
|
pure_getters: "strict",
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
(class {
|
||||||
|
static set p(v) {
|
||||||
|
console.log(v);
|
||||||
|
};
|
||||||
|
}).p = "PASS";
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
(class {
|
||||||
|
static set p(v) {
|
||||||
|
console.log(v);
|
||||||
|
};
|
||||||
|
}).p = "PASS";
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
static_side_effects: {
|
static_side_effects: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user