fix reduce_vars on conditionals (#1822)
This commit is contained in:
parent
6d5f341999
commit
d1aa09c5c7
|
|
@ -348,6 +348,16 @@ merge(Compressor.prototype, {
|
||||||
pop();
|
pop();
|
||||||
return true;
|
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) {
|
if (node instanceof AST_If) {
|
||||||
node.condition.walk(tw);
|
node.condition.walk(tw);
|
||||||
push();
|
push();
|
||||||
|
|
|
||||||
|
|
@ -2240,3 +2240,26 @@ boolean_binary_assign: {
|
||||||
}
|
}
|
||||||
expect_stdout: "undefined"
|
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"
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user