aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-10-30 14:21:22 +0800
committerGitHub <noreply@github.com>2019-10-30 14:21:22 +0800
commitec7f071272384db82dff0f8fb6629f4f6fee43a5 (patch)
tree90db03a953fcaa6f85702951b66b6ba2a715ab6e /lib
parentf1eb03f2c0f860a963b2f61c5f8565d8703a18cb (diff)
downloadtracifyjs-ec7f071272384db82dff0f8fb6629f4f6fee43a5.tar.gz
tracifyjs-ec7f071272384db82dff0f8fb6629f4f6fee43a5.zip
fix corner case in `dead_code` (#3553)
fixes #3552
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 33943ff0..a28c7a6c 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -6433,15 +6433,17 @@ merge(Compressor.prototype, {
OPT(AST_Assign, function(self, compressor) {
if (compressor.option("dead_code")) {
if (self.left instanceof AST_PropAccess) {
- var exp = self.left.expression;
- if (exp instanceof AST_Lambda
- || !compressor.has_directive("use strict")
- && exp instanceof AST_Constant
- && !exp.may_throw_on_access(compressor)) {
- return self.left instanceof AST_Dot ? self.right : make_sequence(self, [
- self.left.property,
- self.right
- ]).optimize(compressor);
+ if (self.operator == "=") {
+ var exp = self.left.expression;
+ if (exp instanceof AST_Lambda
+ || !compressor.has_directive("use strict")
+ && exp instanceof AST_Constant
+ && !exp.may_throw_on_access(compressor)) {
+ return self.left instanceof AST_Dot ? self.right : make_sequence(self, [
+ self.left.property,
+ self.right
+ ]).optimize(compressor);
+ }
}
} else if (self.left instanceof AST_SymbolRef) {
var def = self.left.definition();