aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js9
-rw-r--r--test/compress/const.js22
2 files changed, 28 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 7d5e0221..c4012031 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -6571,14 +6571,17 @@ merge(Compressor.prototype, {
});
});
}
- [].unshift.apply(body, self.body);
- if (self.bfinally) [].push.apply(body, self.bfinally.body);
+ body.unshift(make_node(AST_BlockStatement, self, self).optimize(compressor));
+ if (self.bfinally) {
+ body.push(make_node(AST_BlockStatement, self.bfinally, self.bfinally).optimize(compressor));
+ }
return make_node(AST_BlockStatement, self, {
body: body
}).optimize(compressor);
}
if (self.bfinally && has_declarations_only(self.bfinally)) {
- var body = self.body.concat(self.bfinally.body);
+ var body = make_node(AST_BlockStatement, self.bfinally, self.bfinally).optimize(compressor);
+ body = self.body.concat(body);
if (!self.bcatch) return make_node(AST_BlockStatement, self, {
body: body
}).optimize(compressor);
diff --git a/test/compress/const.js b/test/compress/const.js
index bc37e144..f09dc56f 100644
--- a/test/compress/const.js
+++ b/test/compress/const.js
@@ -725,3 +725,25 @@ issue_4191_2: {
}
expect_stdout: "function undefined"
}
+
+issue_4193: {
+ options = {
+ dead_code: true,
+ }
+ input: {
+ try {} catch (e) {
+ var a;
+ } finally {
+ const a = 0;
+ }
+ console.log(a);
+ }
+ expect: {
+ var a;
+ {
+ const a = 0;
+ }
+ console.log(a);
+ }
+ expect_stdout: true
+}