aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-28 21:25:49 +0800
committerGitHub <noreply@github.com>2017-03-28 21:25:49 +0800
commitc909ffb7156eb99e83afd8e1e75a876039bdc65b (patch)
treee1866f7038b6e23f78582438c2cd114b77519aea /lib
parentf71f4905b004a559f0612e0e0928204f912a66bc (diff)
downloadtracifyjs-c909ffb7156eb99e83afd8e1e75a876039bdc65b.tar.gz
tracifyjs-c909ffb7156eb99e83afd8e1e75a876039bdc65b.zip
fix `unused` on var of the same name within catch (#1716)
fixes #1715
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index c60f8632..64c654dd 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -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,