aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-25 17:40:18 +0800
committerGitHub <noreply@github.com>2017-03-25 17:40:18 +0800
commit6e86ee950d98ebacef7e02515e34d758c4f836a1 (patch)
tree405f6bdf24c28f2041e7304aa43347c4a7811f33 /lib/compress.js
parent8ca2401ebe024287ce1133d2707b1a8ce91f4e6c (diff)
downloadtracifyjs-6e86ee950d98ebacef7e02515e34d758c4f836a1.tar.gz
tracifyjs-6e86ee950d98ebacef7e02515e34d758c4f836a1.zip
fix typeof side-effects (#1669)
`has_side_effects()` does not take `typeof`'s magical power of not tripping over undeclared variable into account. fixes #1668
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 47eb4d73..e12c5eb0 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3013,10 +3013,10 @@ merge(Compressor.prototype, {
// typeof always returns a non-empty string, thus it's
// always true in booleans
compressor.warn("Boolean expression always true [{file}:{line},{col}]", self.start);
- return make_node(AST_Seq, self, {
+ return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_node(AST_Seq, self, {
car: e,
cdr: make_node(AST_True, self)
- }).optimize(compressor);
+ })).optimize(compressor);
}
}
// avoids infinite recursion of numerals