aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-01-30 00:08:53 +0800
committerGitHub <noreply@github.com>2020-01-30 00:08:53 +0800
commita3754068dde7a51ab41b59a6d8a17a3a8c022564 (patch)
treebbf713958d95e4e5d558f7173959f0dfce7fb48f /lib
parent2ba5f391e008b5d842571094d1140f9ae888ea4d (diff)
downloadtracifyjs-a3754068dde7a51ab41b59a6d8a17a3a8c022564.tar.gz
tracifyjs-a3754068dde7a51ab41b59a6d8a17a3a8c022564.zip
fix corner case in `collapse_vars` (#3699)
fixes #3698
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 85ad449e..e6a064dd 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1094,6 +1094,7 @@ merge(Compressor.prototype, {
collapse(statements, compressor);
}
} while (CHANGED && max_iter-- > 0);
+ return statements;
function find_loop_scope_try() {
var node = compressor.self(), level = 0;
@@ -1150,11 +1151,10 @@ merge(Compressor.prototype, {
if (node.single_use && parent instanceof AST_VarDef && parent.value === node) return node;
// Replace variable with assignment when found
var hit_rhs;
- if (can_replace
- && !(node instanceof AST_SymbolDeclaration)
+ if (!(node instanceof AST_SymbolDeclaration)
&& (scan_lhs && lhs.equivalent_to(node)
|| scan_rhs && (hit_rhs = scan_rhs(node, this)))) {
- if (stop_if_hit && (hit_rhs || !lhs_local || !replace_all)) {
+ if (!can_replace || stop_if_hit && (hit_rhs || !lhs_local || !replace_all)) {
if (!hit_rhs || !value_def) abort = true;
return node;
}
@@ -3854,12 +3854,12 @@ merge(Compressor.prototype, {
});
OPT(AST_Block, function(self, compressor) {
- tighten_body(self.body, compressor);
+ self.body = tighten_body(self.body, compressor);
return self;
});
OPT(AST_BlockStatement, function(self, compressor) {
- tighten_body(self.body, compressor);
+ self.body = tighten_body(self.body, compressor);
switch (self.body.length) {
case 1: return self.body[0];
case 0: return make_node(AST_EmptyStatement, self);
@@ -3868,7 +3868,7 @@ merge(Compressor.prototype, {
});
OPT(AST_Lambda, function(self, compressor) {
- tighten_body(self.body, compressor);
+ self.body = tighten_body(self.body, compressor);
if (compressor.option("side_effects")
&& self.body.length == 1
&& self.body[0] === compressor.has_directive("use strict")) {
@@ -5372,7 +5372,7 @@ merge(Compressor.prototype, {
});
OPT(AST_Try, function(self, compressor) {
- tighten_body(self.body, compressor);
+ self.body = tighten_body(self.body, compressor);
if (self.bcatch && self.bfinally && all(self.bfinally.body, is_empty)) self.bfinally = null;
if (compressor.option("dead_code") && all(self.body, is_empty)) {
var body = [];