aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-10-24 01:13:57 +0800
committerGitHub <noreply@github.com>2019-10-24 01:13:57 +0800
commit0f7aa41e339b574ee0f67c093438d356a8a85477 (patch)
tree21ae6f719c7310c46e8e0edf2f099481a76aa756 /lib/compress.js
parent370c8e03855f17d73e8a0f75ae0b9b40e31e47e9 (diff)
downloadtracifyjs-0f7aa41e339b574ee0f67c093438d356a8a85477.tar.gz
tracifyjs-0f7aa41e339b574ee0f67c093438d356a8a85477.zip
fix corner case in `collapse_vars` (#3521)
fixes #3520
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 7202219a..c8eb3487 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1128,6 +1128,8 @@ merge(Compressor.prototype, {
if (!stop_if_hit && in_conditional(node, parent)) {
stop_if_hit = parent;
}
+ // Skip transient nodes caused by single-use variable replacement
+ 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
@@ -3737,9 +3739,7 @@ merge(Compressor.prototype, {
def.value = null;
head.push(def);
} else {
- var value = def.value
- && !def.value.single_use
- && def.value.drop_side_effect_free(compressor);
+ var value = def.value && def.value.drop_side_effect_free(compressor);
if (value) {
AST_Node.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", template(def.name));
side_effects.push(value);