aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-09-26 08:31:33 +0100
committerGitHub <noreply@github.com>2020-09-26 15:31:33 +0800
commitb4ff6d0f2da3f094cf1bb4897a2dc67ad4f3efa5 (patch)
treea4ac8b3aed1a702275516c41e93aae1fb5969e8b /lib
parent9882a9f4af95af4b0cba0a4a60a695ba2f6de04d (diff)
downloadtracifyjs-b4ff6d0f2da3f094cf1bb4897a2dc67ad4f3efa5.tar.gz
tracifyjs-b4ff6d0f2da3f094cf1bb4897a2dc67ad4f3efa5.zip
fix corner cases in `functions` & `merge_vars` (#4156)
fixes #4155
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 3f7eee68..25a993f6 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4449,7 +4449,9 @@ merge(Compressor.prototype, {
segment.block = node;
walk_body(node, tw);
if (node.bcatch) {
- references[node.bcatch.argname.definition().id] = false;
+ var def = node.bcatch.argname.definition();
+ references[def.id] = false;
+ if (def = def.redefined()) references[def.id] = false;
pop();
push();
walk_body(node.bcatch, tw);
@@ -4843,8 +4845,10 @@ merge(Compressor.prototype, {
&& !compressor.option("ie8")
&& var_defs.length == 1
&& sym.assignments == 0
- && def.value === def.name.fixed_value()
&& def.value instanceof AST_Function
+ && (sym.references.length ? all(sym.references, function(ref) {
+ return def.value === ref.fixed_value();
+ }) : def.value === def.name.fixed_value())
&& (!def.value.name || (old_def = def.value.name.definition()).assignments == 0
&& (old_def.name == def.name.name || all(old_def.references, function(ref) {
return ref.scope.find_variable(def.name) === def.name.definition();