@@ -5395,7 +5395,8 @@ merge(Compressor.prototype, {
|
|||||||
|
|
||||||
OPT(AST_UnaryPrefix, function(self, compressor) {
|
OPT(AST_UnaryPrefix, function(self, compressor) {
|
||||||
var e = self.expression;
|
var e = self.expression;
|
||||||
if (self.operator == "delete"
|
if (compressor.option("evaluate")
|
||||||
|
&& self.operator == "delete"
|
||||||
&& !(e instanceof AST_SymbolRef
|
&& !(e instanceof AST_SymbolRef
|
||||||
|| e instanceof AST_PropAccess
|
|| e instanceof AST_PropAccess
|
||||||
|| is_identifier_atom(e))) {
|
|| is_identifier_atom(e))) {
|
||||||
@@ -6254,6 +6255,7 @@ merge(Compressor.prototype, {
|
|||||||
if (compressor.option("dead_code")
|
if (compressor.option("dead_code")
|
||||||
&& self.left instanceof AST_SymbolRef
|
&& self.left instanceof AST_SymbolRef
|
||||||
&& (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
|
&& (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
|
||||||
|
if (self.left.is_immutable()) return strip_assignment();
|
||||||
var level = 0, node, parent = self;
|
var level = 0, node, parent = self;
|
||||||
do {
|
do {
|
||||||
node = parent;
|
node = parent;
|
||||||
@@ -6261,16 +6263,12 @@ merge(Compressor.prototype, {
|
|||||||
if (parent instanceof AST_Exit) {
|
if (parent instanceof AST_Exit) {
|
||||||
if (in_try(level, parent)) break;
|
if (in_try(level, parent)) break;
|
||||||
if (is_reachable(def.scope, [ def ])) break;
|
if (is_reachable(def.scope, [ def ])) break;
|
||||||
if (self.operator == "=") return self.right.optimize(compressor);
|
|
||||||
def.fixed = false;
|
def.fixed = false;
|
||||||
return make_node(AST_Binary, self, {
|
return strip_assignment();
|
||||||
operator: self.operator.slice(0, -1),
|
|
||||||
left: self.left,
|
|
||||||
right: self.right
|
|
||||||
}).optimize(compressor);
|
|
||||||
}
|
}
|
||||||
} while (parent instanceof AST_Binary && parent.right === node
|
} while (parent instanceof AST_Binary && parent.right === node
|
||||||
|| parent instanceof AST_Sequence && parent.tail_node() === node);
|
|| parent instanceof AST_Sequence && parent.tail_node() === node
|
||||||
|
|| parent instanceof AST_UnaryPrefix);
|
||||||
}
|
}
|
||||||
self = self.lift_sequences(compressor);
|
self = self.lift_sequences(compressor);
|
||||||
if (!compressor.option("assignments")) return self;
|
if (!compressor.option("assignments")) return self;
|
||||||
@@ -6302,13 +6300,6 @@ merge(Compressor.prototype, {
|
|||||||
expression: self.left
|
expression: self.left
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!compressor.option("ie8") && self.left instanceof AST_Symbol && self.left.is_immutable()) {
|
|
||||||
return (self.operator == "=" ? self.right : make_node(AST_Binary, self, {
|
|
||||||
operator: self.operator.slice(0, -1),
|
|
||||||
left: self.left,
|
|
||||||
right: self.right
|
|
||||||
})).optimize(compressor);
|
|
||||||
}
|
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
function in_try(level, node) {
|
function in_try(level, node) {
|
||||||
@@ -6325,6 +6316,14 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function strip_assignment() {
|
||||||
|
return (self.operator != "=" ? make_node(AST_Binary, self, {
|
||||||
|
operator: self.operator.slice(0, -1),
|
||||||
|
left: self.left,
|
||||||
|
right: self.right
|
||||||
|
}) : maintain_this_binding(compressor, compressor.parent(), self, self.right)).optimize(compressor);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
OPT(AST_Conditional, function(self, compressor) {
|
OPT(AST_Conditional, function(self, compressor) {
|
||||||
|
|||||||
@@ -311,39 +311,3 @@ issue_3375: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "string"
|
expect_stdout: "string"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_3402: {
|
|
||||||
options = {
|
|
||||||
assignments: true,
|
|
||||||
evaluate: true,
|
|
||||||
functions: true,
|
|
||||||
passes: 2,
|
|
||||||
reduce_vars: true,
|
|
||||||
side_effects: true,
|
|
||||||
toplevel: true,
|
|
||||||
typeofs: true,
|
|
||||||
unused: true,
|
|
||||||
}
|
|
||||||
input: {
|
|
||||||
var f = function f() {
|
|
||||||
f = 42;
|
|
||||||
console.log(typeof f);
|
|
||||||
};
|
|
||||||
"function" == typeof f && f();
|
|
||||||
"function" == typeof f && f();
|
|
||||||
console.log(typeof f);
|
|
||||||
}
|
|
||||||
expect: {
|
|
||||||
function f() {
|
|
||||||
console.log(typeof f);
|
|
||||||
}
|
|
||||||
f();
|
|
||||||
f();
|
|
||||||
console.log(typeof f);
|
|
||||||
}
|
|
||||||
expect_stdout: [
|
|
||||||
"function",
|
|
||||||
"function",
|
|
||||||
"function",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -960,3 +960,56 @@ unsafe_string_replace: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3402: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
functions: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
typeofs: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var f = function f() {
|
||||||
|
f = 42;
|
||||||
|
console.log(typeof f);
|
||||||
|
};
|
||||||
|
"function" == typeof f && f();
|
||||||
|
"function" == typeof f && f();
|
||||||
|
console.log(typeof f);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
console.log(typeof f);
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
f();
|
||||||
|
console.log(typeof f);
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"function",
|
||||||
|
"function",
|
||||||
|
"function",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3406: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function f(a) {
|
||||||
|
return delete (f = a);
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function f(a) {
|
||||||
|
return delete (0, a);
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1005,7 +1005,7 @@ issue_1715_4: {
|
|||||||
delete_assign_1: {
|
delete_assign_1: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
side_effects: true,
|
evaluate: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
@@ -1024,7 +1024,7 @@ delete_assign_1: {
|
|||||||
console.log((1 / 0, !0));
|
console.log((1 / 0, !0));
|
||||||
console.log((1 / 0, !0));
|
console.log((1 / 0, !0));
|
||||||
console.log((NaN, !0));
|
console.log((NaN, !0));
|
||||||
console.log((0 / 0, !0));
|
console.log((NaN, !0));
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
@@ -1032,8 +1032,8 @@ delete_assign_1: {
|
|||||||
delete_assign_2: {
|
delete_assign_2: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
keep_infinity: true,
|
keep_infinity: true,
|
||||||
side_effects: true,
|
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
@@ -1052,7 +1052,7 @@ delete_assign_2: {
|
|||||||
console.log((Infinity, !0));
|
console.log((Infinity, !0));
|
||||||
console.log((1 / 0, !0));
|
console.log((1 / 0, !0));
|
||||||
console.log((NaN, !0));
|
console.log((NaN, !0));
|
||||||
console.log((0 / 0, !0));
|
console.log((NaN, !0));
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -490,6 +490,7 @@ issue_1758: {
|
|||||||
delete_seq_1: {
|
delete_seq_1: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -514,6 +515,7 @@ delete_seq_1: {
|
|||||||
delete_seq_2: {
|
delete_seq_2: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -538,6 +540,7 @@ delete_seq_2: {
|
|||||||
delete_seq_3: {
|
delete_seq_3: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
keep_infinity: true,
|
keep_infinity: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
}
|
}
|
||||||
@@ -563,6 +566,7 @@ delete_seq_3: {
|
|||||||
delete_seq_4: {
|
delete_seq_4: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
}
|
}
|
||||||
@@ -590,6 +594,7 @@ delete_seq_4: {
|
|||||||
delete_seq_5: {
|
delete_seq_5: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
keep_infinity: true,
|
keep_infinity: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
@@ -618,6 +623,7 @@ delete_seq_5: {
|
|||||||
delete_seq_6: {
|
delete_seq_6: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
Reference in New Issue
Block a user