handle case correctly under reduce_vars (#2993)

fixes #2992
This commit is contained in:
Alex Lam S.L
2018-03-11 15:54:43 +08:00
committed by GitHub
parent fc6ebd04a5
commit b9f72a4a81
2 changed files with 45 additions and 6 deletions

View File

@@ -517,6 +517,15 @@ merge(Compressor.prototype, {
pop(tw);
return true;
});
def(AST_Case, function(tw) {
push(tw);
this.expression.walk(tw);
pop(tw);
push(tw);
walk_body(this, tw);
pop(tw);
return true;
});
def(AST_Conditional, function(tw) {
this.condition.walk(tw);
push(tw);
@@ -527,6 +536,12 @@ merge(Compressor.prototype, {
pop(tw);
return true;
});
def(AST_Default, function(tw, descend) {
push(tw);
descend();
pop(tw);
return true;
});
def(AST_Defun, function(tw, descend, compressor) {
this.inlined = false;
var save_ids = tw.safe_ids;
@@ -624,12 +639,6 @@ merge(Compressor.prototype, {
pop(tw);
return true;
});
def(AST_SwitchBranch, function(tw, descend) {
push(tw);
descend();
pop(tw);
return true;
});
def(AST_SymbolCatch, function() {
this.definition().fixed = false;
});

View File

@@ -5545,3 +5545,33 @@ issue_2919: {
}
expect_stdout: "function"
}
issue_2992: {
options = {
evaluate: true,
reduce_vars: true,
}
input: {
var c = "PASS";
(function f(b) {
switch (0) {
case 0:
case b = 1:
b && (c = "FAIL");
}
})();
console.log(c);
}
expect: {
var c = "PASS";
(function f(b) {
switch (0) {
case 0:
case b = 1:
b && (c = "FAIL");
}
})();
console.log(c);
}
expect_stdout: "PASS"
}