aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js10
-rw-r--r--test/compress/reduce_vars.js23
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index f49dd60e..0dfe2a3c 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -348,6 +348,16 @@ merge(Compressor.prototype, {
pop();
return true;
}
+ if (node instanceof AST_Conditional) {
+ node.condition.walk(tw);
+ push();
+ node.consequent.walk(tw);
+ pop();
+ push();
+ node.alternative.walk(tw);
+ pop();
+ return true;
+ }
if (node instanceof AST_If) {
node.condition.walk(tw);
push();
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 94d37cb7..ad2c90bc 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -2240,3 +2240,26 @@ boolean_binary_assign: {
}
expect_stdout: "undefined"
}
+
+cond_assign: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ !function() {
+ var a;
+ void 0 ? (a = 1) : 0;
+ console.log(a);
+ }();
+ }
+ expect: {
+ !function() {
+ var a;
+ void 0 ? (a = 1) : 0;
+ console.log(a);
+ }();
+ }
+ expect_stdout: "undefined"
+}