@@ -1429,6 +1429,7 @@ merge(Compressor.prototype, {
|
||||
}
|
||||
}
|
||||
|
||||
var identifier_atom = makePredicate("Infinity NaN undefined");
|
||||
function is_lhs_read_only(lhs, compressor) {
|
||||
if (lhs instanceof AST_ObjectIdentity) return true;
|
||||
if (lhs instanceof AST_PropAccess) {
|
||||
@@ -1616,13 +1617,6 @@ merge(Compressor.prototype, {
|
||||
|| compressor.option("unsafe") && global_names[this.name];
|
||||
});
|
||||
|
||||
var identifier_atom = makePredicate("Infinity NaN undefined");
|
||||
function is_identifier_atom(node) {
|
||||
return node instanceof AST_Infinity
|
||||
|| node instanceof AST_NaN
|
||||
|| node instanceof AST_Undefined;
|
||||
}
|
||||
|
||||
function declarations_only(node) {
|
||||
return all(node.definitions, function(var_def) {
|
||||
return !var_def.value;
|
||||
@@ -9438,11 +9432,7 @@ merge(Compressor.prototype, {
|
||||
OPT(AST_UnaryPrefix, function(self, compressor) {
|
||||
var op = self.operator;
|
||||
var exp = self.expression;
|
||||
if (compressor.option("evaluate")
|
||||
&& op == "delete"
|
||||
&& !(exp instanceof AST_SymbolRef
|
||||
|| exp instanceof AST_PropAccess
|
||||
|| is_identifier_atom(exp))) {
|
||||
if (compressor.option("evaluate") && op == "delete" && !may_not_delete(exp)) {
|
||||
return make_sequence(self, [ exp, make_node(AST_True, self) ]).optimize(compressor);
|
||||
}
|
||||
if (compressor.option("sequences") && can_lift()) {
|
||||
@@ -9496,10 +9486,19 @@ merge(Compressor.prototype, {
|
||||
return op == "-" && (exp instanceof AST_Number || exp instanceof AST_Infinity)
|
||||
? self : try_evaluate(compressor, self);
|
||||
|
||||
function may_not_delete(node) {
|
||||
return node instanceof AST_Infinity
|
||||
|| node instanceof AST_NaN
|
||||
|| node instanceof AST_NewTarget
|
||||
|| node instanceof AST_PropAccess
|
||||
|| node instanceof AST_SymbolRef
|
||||
|| node instanceof AST_Undefined;
|
||||
}
|
||||
|
||||
function can_lift() {
|
||||
switch (op) {
|
||||
case "delete":
|
||||
return !is_identifier_atom(exp.tail_node());
|
||||
return !may_not_delete(exp.tail_node());
|
||||
case "typeof":
|
||||
return !is_undeclared_ref(exp.tail_node());
|
||||
default:
|
||||
|
||||
@@ -5851,6 +5851,24 @@ new_target_collapse_vars: {
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
new_target_delete: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
}
|
||||
input: {
|
||||
new function() {
|
||||
console.log(delete new.target);
|
||||
}();
|
||||
}
|
||||
expect: {
|
||||
new function() {
|
||||
console.log(delete new.target);
|
||||
}();
|
||||
}
|
||||
expect_stdout: true
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
new_target_reduce_vars: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
|
||||
Reference in New Issue
Block a user