enhance unused (#3800)
This commit is contained in:
@@ -4200,8 +4200,15 @@ merge(Compressor.prototype, {
|
|||||||
} else if (sym.orig[0] instanceof AST_SymbolCatch) {
|
} else if (sym.orig[0] instanceof AST_SymbolCatch) {
|
||||||
var value = def.value && def.value.drop_side_effect_free(compressor);
|
var value = def.value && def.value.drop_side_effect_free(compressor);
|
||||||
if (value) side_effects.push(value);
|
if (value) side_effects.push(value);
|
||||||
def.value = null;
|
var var_defs = var_defs_by_id.get(sym.id);
|
||||||
head.push(def);
|
if (var_defs.length > 1) {
|
||||||
|
AST_Node.warn("Dropping duplicated declaration of variable {name} [{file}:{line},{col}]", template(def.name));
|
||||||
|
remove(var_defs, def);
|
||||||
|
sym.eliminated++;
|
||||||
|
} else {
|
||||||
|
def.value = null;
|
||||||
|
head.push(def);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var value = def.value && !def.value.single_use && def.value.drop_side_effect_free(compressor);
|
var value = def.value && !def.value.single_use && def.value.drop_side_effect_free(compressor);
|
||||||
if (value) {
|
if (value) {
|
||||||
|
|||||||
@@ -1173,7 +1173,6 @@ var_catch_toplevel: {
|
|||||||
x();
|
x();
|
||||||
} catch (a) {
|
} catch (a) {
|
||||||
var a;
|
var a;
|
||||||
var a;
|
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
@@ -2465,3 +2464,27 @@ drop_duplicated_side_effects: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "1"
|
expect_stdout: "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drop_duplicated_var_catch: {
|
||||||
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
try {
|
||||||
|
x();
|
||||||
|
} catch (a) {
|
||||||
|
var a, a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
try {
|
||||||
|
x();
|
||||||
|
} catch (a) {
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user