aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-10-13 17:09:17 +0100
committerGitHub <noreply@github.com>2020-10-14 00:09:17 +0800
commitc0c04c33bb1652014365fa893cc9b7d29684e59a (patch)
treeb6bbfcf28439c013434f5fd434550da3194fc3e4 /lib
parent0e234a25c52bcfc873fc1ac287995be08a6756aa (diff)
downloadtracifyjs-c0c04c33bb1652014365fa893cc9b7d29684e59a.tar.gz
tracifyjs-c0c04c33bb1652014365fa893cc9b7d29684e59a.zip
fix corner cases in `dead_code` & `reduce_vars` (#4213)
fixes #4212
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js
index e36fcaa7..5dd10c6c 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -485,9 +485,10 @@ merge(Compressor.prototype, {
}
function safe_to_assign(tw, def, declare) {
- if (def.fixed === undefined) return declare || all(def.orig, function(sym) {
+ if (!(declare || all(def.orig, function(sym) {
return !(sym instanceof AST_SymbolConst);
- });
+ }))) return false;
+ if (def.fixed === undefined) return true;
if (def.fixed === null && def.safe_ids) {
def.safe_ids[def.id] = false;
delete def.safe_ids;
@@ -8557,7 +8558,9 @@ merge(Compressor.prototype, {
]).optimize(compressor);
}
}
- } else if (self.left instanceof AST_SymbolRef) {
+ } else if (self.left instanceof AST_SymbolRef && all(self.left.definition().orig, function(sym) {
+ return !(sym instanceof AST_SymbolConst);
+ })) {
var parent;
if (self.operator == "=" && self.left.equivalent_to(self.right)
&& !((parent = compressor.parent()) instanceof AST_UnaryPrefix && parent.operator == "delete")) {