fix unused on var of the same name within catch (#1716)

fixes #1715
This commit is contained in:
Alex Lam S.L
2017-03-28 21:25:49 +08:00
committed by GitHub
parent f71f4905b0
commit c909ffb715
2 changed files with 94 additions and 1 deletions

View File

@@ -1894,7 +1894,13 @@ merge(Compressor.prototype, {
if (drop_vars && node instanceof AST_Definitions && !(tt.parent() instanceof AST_ForIn)) {
var def = node.definitions.filter(function(def){
if (def.value) def.value = def.value.transform(tt);
if (def.name.definition().id in in_use_ids) return true;
var sym = def.name.definition();
if (sym.id in in_use_ids) return true;
if (sym.orig[0] instanceof AST_SymbolCatch
&& sym.scope.parent_scope.find_variable(def.name).orig[0] === def.name) {
def.value = def.value && def.value.drop_side_effect_free(compressor);
return true;
}
var w = {
name : def.name.name,
file : def.name.start.file,