aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-22 00:21:21 +0000
committerGitHub <noreply@github.com>2021-02-22 08:21:21 +0800
commit55b59407e44bcccf0068d6ae2dc3f446d60809b4 (patch)
tree782d8dd1ea1ca6d96fcb06a7c00cff0adf226bfc /lib
parentb726e364c1164b0c828d7be04bfcfa21774366a1 (diff)
downloadtracifyjs-55b59407e44bcccf0068d6ae2dc3f446d60809b4.tar.gz
tracifyjs-55b59407e44bcccf0068d6ae2dc3f446d60809b4.zip
fix corner cases in `reduce_vars` (#4674)
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 7577437e..0a89de7e 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -374,12 +374,20 @@ merge(Compressor.prototype, {
var lhs = is_lhs(node, parent);
if (lhs) return lhs;
if (parent instanceof AST_Array) return is_modified(compressor, tw, parent, parent, level + 1);
+ if (parent instanceof AST_Binary) {
+ if (!lazy_op[parent.operator]) return;
+ return is_modified(compressor, tw, parent, parent, level + 1);
+ }
if (parent instanceof AST_Call) {
return !immutable
&& parent.expression === node
&& !parent.is_expr_pure(compressor)
&& (!(value instanceof AST_LambdaExpression) || !(parent instanceof AST_New) && value.contains_this());
}
+ if (parent instanceof AST_Conditional) {
+ if (parent.condition === node) return;
+ return is_modified(compressor, tw, parent, parent, level + 1);
+ }
if (parent instanceof AST_ForEnumeration) return parent.init === node;
if (parent instanceof AST_ObjectKeyVal) {
if (parent.value !== node) return;
@@ -391,6 +399,10 @@ merge(Compressor.prototype, {
var prop = read_property(value, parent);
return (!immutable || recursive) && is_modified(compressor, tw, parent, prop, level + 1);
}
+ if (parent instanceof AST_Sequence) {
+ if (parent.tail_node() !== node) return;
+ return is_modified(compressor, tw, parent, value, level + 1, immutable, recursive);
+ }
}
function is_arguments(def) {