diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-15 19:41:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-15 19:41:28 +0800 |
commit | 7d6907cb99bac1e835febe30494ebca4c1a671d3 (patch) | |
tree | bdcd521b213b7eac563541d02bbf7eaddde9c254 /lib/compress.js | |
parent | 092d9affb829768e652f14c82080e27893e1f022 (diff) | |
download | tracifyjs-7d6907cb99bac1e835febe30494ebca4c1a671d3.tar.gz tracifyjs-7d6907cb99bac1e835febe30494ebca4c1a671d3.zip |
fix `dead_code` on nested `try` (#2599)
fixes #2597
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/compress.js b/lib/compress.js index 0162fa4e..a8bcf54f 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4751,11 +4751,7 @@ merge(Compressor.prototype, { node = parent; parent = compressor.parent(level++); if (parent instanceof AST_Exit) { - var try_node = find_try(level); - if (try_node) { - if (try_node.bfinally) break; - if (parent instanceof AST_Throw && try_node.bcatch) break; - } + if (in_try(level, parent instanceof AST_Throw)) break; if (self.operator == "=") return self.right; return make_node(AST_Binary, self, { operator: self.operator.slice(0, -1), @@ -4787,11 +4783,14 @@ merge(Compressor.prototype, { } return self; - function find_try(level) { + function in_try(level, no_catch) { var scope = self.left.definition().scope; var parent; while ((parent = compressor.parent(level++)) !== scope) { - if (parent instanceof AST_Try) return parent; + if (parent instanceof AST_Try) { + if (parent.bfinally) return true; + if (no_catch && parent.bcatch) return true; + } } } }); |