aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js4
-rw-r--r--test/compress/hoist_vars.js32
2 files changed, 34 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 4bc57012..fd0564cb 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -7700,6 +7700,7 @@ merge(Compressor.prototype, {
def.references.push(name);
}
def.eliminated++;
+ def.single_use = false;
return a;
}, []);
if (assignments.length == 0) return null;
@@ -9702,7 +9703,8 @@ merge(Compressor.prototype, {
}
}));
} else {
- value = fixed.optimize(compressor).transform(new TreeTransformer(function(node, descend) {
+ value = fixed.optimize(compressor);
+ if (value === fixed) value = value.transform(new TreeTransformer(function(node, descend) {
if (node instanceof AST_Scope) return node;
node = node.clone();
descend(node, this);
diff --git a/test/compress/hoist_vars.js b/test/compress/hoist_vars.js
index 82f8ede6..020155aa 100644
--- a/test/compress/hoist_vars.js
+++ b/test/compress/hoist_vars.js
@@ -172,8 +172,38 @@ issue_4489: {
A = 0;
var o = !0 || null;
for (var k in o);
+ console.log(k);
}
expect: {
- for (var k in !(A = 0));
+ !(A = 0);
+ for (var k in true);
+ console.log(k);
}
+ expect_stdout: "undefined"
+}
+
+issue_4517: {
+ options = {
+ collapse_vars: true,
+ hoist_vars: true,
+ join_vars: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ console.log(function() {
+ var a = 2;
+ A = a;
+ var b = typeof !1;
+ return A + b;
+ }());
+ }
+ expect: {
+ console.log(function() {
+ var a = 2;
+ A = a;
+ return A + typeof !1;
+ }());
+ }
+ expect_stdout: "2boolean"
}