aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-24 02:56:22 +0000
committerGitHub <noreply@github.com>2020-12-24 10:56:22 +0800
commit5f269cd57356fc4dbe7486dca22902d22695d499 (patch)
tree1a7ac6838449a7b154d411547d75be784c361aa2 /lib/compress.js
parent6988cd95584ce8b66716c17afad9d2dcc71717d0 (diff)
downloadtracifyjs-5f269cd57356fc4dbe7486dca22902d22695d499.tar.gz
tracifyjs-5f269cd57356fc4dbe7486dca22902d22695d499.zip
fix corner case in `collapse_vars` (#4445)
fixes #4444
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 4351768d..a611bf4a 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1814,16 +1814,22 @@ merge(Compressor.prototype, {
}
if (!(fn instanceof AST_Lambda)) return true;
if (def && recursive_ref(compressor, def)) return true;
- if (!all(fn.argnames, function(argname) {
- return !(argname instanceof AST_Destructured);
- })) return true;
if (fn.collapse_scanning) return false;
fn.collapse_scanning = true;
var replace = can_replace;
can_replace = false;
var after = stop_after;
var if_hit = stop_if_hit;
- if (fn instanceof AST_Arrow && fn.value) {
+ if (!all(fn.argnames, function(argname) {
+ if (argname instanceof AST_DefaultValue) {
+ argname.value.transform(scanner);
+ if (abort) return false;
+ argname = argname.name;
+ }
+ return !(argname instanceof AST_Destructured);
+ })) {
+ abort = true;
+ } else if (fn instanceof AST_Arrow && fn.value) {
fn.value.transform(scanner);
} else for (var i = 0; !abort && i < fn.body.length; i++) {
var stat = fn.body[i];