@@ -3682,6 +3682,7 @@ merge(Compressor.prototype, {
|
||||
} else if (compressor.option("functions")
|
||||
&& def.value === def.name.fixed_value()
|
||||
&& def.value instanceof AST_Function
|
||||
&& !(def.value.name && def.value.name.definition().assignments)
|
||||
&& can_rename(def.value, def.name.name)
|
||||
&& (!compressor.has_directive("use strict") || parent instanceof AST_Scope)) {
|
||||
AST_Node.warn("Declaring {name} as function [{file}:{line},{col}]", template(def.name));
|
||||
@@ -6301,6 +6302,13 @@ merge(Compressor.prototype, {
|
||||
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;
|
||||
|
||||
function in_try(level, node) {
|
||||
|
||||
@@ -311,3 +311,39 @@ issue_3375: {
|
||||
}
|
||||
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",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3113,3 +3113,38 @@ issue_3400: {
|
||||
"42",
|
||||
]
|
||||
}
|
||||
|
||||
issue_3402: {
|
||||
options = {
|
||||
evaluate: true,
|
||||
functions: true,
|
||||
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: {
|
||||
var f = function f() {
|
||||
f = 42;
|
||||
console.log(typeof f);
|
||||
};
|
||||
f();
|
||||
f();
|
||||
console.log(typeof f);
|
||||
}
|
||||
expect_stdout: [
|
||||
"function",
|
||||
"function",
|
||||
"function",
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user