aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-03-07 02:33:51 +0000
committerGitHub <noreply@github.com>2021-03-07 10:33:51 +0800
commit397e48b97e18cf947c9c9eec0f66589cb92689a3 (patch)
treeb7c4a68d9894fe410b9bcdb3b67222238732f5bf /lib
parentc7520b4b971c0afcfb66a9ffa215d0d8e4a6fabe (diff)
downloadtracifyjs-397e48b97e18cf947c9c9eec0f66589cb92689a3.tar.gz
tracifyjs-397e48b97e18cf947c9c9eec0f66589cb92689a3.zip
fix corner case in `collapse_vars` & `reduce_vars` (#4748)
fixes #4747
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/compress.js b/lib/compress.js
index be586a88..0069570c 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5188,6 +5188,12 @@ merge(Compressor.prototype, {
fn.rest = null;
}
+ OPT(AST_Lambda, function(self, compressor) {
+ drop_rest_farg(self, compressor);
+ self.body = tighten_body(self.body, compressor);
+ return self;
+ });
+
function opt_arrow(self, compressor) {
if (!compressor.option("arrows")) return self;
drop_rest_farg(self, compressor);
@@ -5210,12 +5216,6 @@ merge(Compressor.prototype, {
OPT(AST_Arrow, opt_arrow);
OPT(AST_AsyncArrow, opt_arrow);
- OPT(AST_Defun, function(self, compressor) {
- drop_rest_farg(self, compressor);
- self.body = tighten_body(self.body, compressor);
- return self;
- });
-
OPT(AST_Function, function(self, compressor) {
drop_rest_farg(self, compressor);
self.body = tighten_body(self.body, compressor);
@@ -10389,7 +10389,13 @@ merge(Compressor.prototype, {
}
}));
} else {
- value = fixed.optimize(compressor);
+ if (fixed instanceof AST_Scope) {
+ compressor.push(fixed);
+ value = fixed.optimize(compressor);
+ compressor.pop();
+ } else {
+ value = fixed.optimize(compressor);
+ }
if (value === fixed) value = value.transform(new TreeTransformer(function(node, descend) {
if (node instanceof AST_Scope) return node;
node = node.clone();