@@ -4151,22 +4151,17 @@ merge(Compressor.prototype, {
|
|||||||
def.value = def.value.drop_side_effect_free(compressor);
|
def.value = def.value.drop_side_effect_free(compressor);
|
||||||
}
|
}
|
||||||
var var_defs = var_defs_by_id.get(sym.id);
|
var var_defs = var_defs_by_id.get(sym.id);
|
||||||
if (var_defs.length > 1) {
|
if (!def.value) {
|
||||||
if (!def.value) {
|
if (var_defs.length > 1) {
|
||||||
AST_Node.warn("Dropping duplicated declaration of variable {name} [{file}:{line},{col}]", template(def.name));
|
AST_Node.warn("Dropping duplicated declaration of variable {name} [{file}:{line},{col}]", template(def.name));
|
||||||
remove(var_defs, def);
|
remove(var_defs, def);
|
||||||
sym.eliminated++;
|
sym.eliminated++;
|
||||||
return;
|
} else {
|
||||||
|
head.push(def);
|
||||||
}
|
}
|
||||||
if (sym.orig.indexOf(def.name) > sym.eliminated) {
|
|
||||||
remove(var_defs, def);
|
|
||||||
duplicated++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!def.value) {
|
|
||||||
head.push(def);
|
|
||||||
} else if (compressor.option("functions")
|
} else if (compressor.option("functions")
|
||||||
&& !compressor.option("ie8")
|
&& !compressor.option("ie8")
|
||||||
|
&& var_defs.length == 1
|
||||||
&& def.value === def.name.fixed_value()
|
&& def.value === def.name.fixed_value()
|
||||||
&& def.value instanceof AST_Function
|
&& def.value instanceof AST_Function
|
||||||
&& !(def.value.name && def.value.name.definition().assignments)
|
&& !(def.value.name && def.value.name.definition().assignments)
|
||||||
@@ -4188,6 +4183,10 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
body.push(defun);
|
body.push(defun);
|
||||||
} else {
|
} else {
|
||||||
|
if (var_defs.length > 1 && sym.orig.indexOf(def.name) > sym.eliminated) {
|
||||||
|
remove(var_defs, def);
|
||||||
|
duplicated++;
|
||||||
|
}
|
||||||
if (side_effects.length > 0) {
|
if (side_effects.length > 0) {
|
||||||
if (tail.length > 0) {
|
if (tail.length > 0) {
|
||||||
side_effects.push(def.value);
|
side_effects.push(def.value);
|
||||||
|
|||||||
@@ -2488,3 +2488,25 @@ drop_duplicated_var_catch: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3802: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 0;
|
||||||
|
a += 0;
|
||||||
|
var a = function() {};
|
||||||
|
console.log(typeof a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 0;
|
||||||
|
a += 0;
|
||||||
|
a = function() {};
|
||||||
|
console.log(typeof a);
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user