fix side-effects detection on switch statements (#1678)

extension of #1675
This commit is contained in:
Alex Lam S.L
2017-03-26 12:05:44 +08:00
committed by GitHub
parent adb0e882e9
commit 8a4f86528f
2 changed files with 36 additions and 0 deletions

View File

@@ -125,3 +125,35 @@ side_effects_label: {
}
expect_stdout: "PASS"
}
side_effects_switch: {
options = {
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
function f() {
function g() {
switch (0) {
default:
case console.log("PASS"):
}
}
g();
}
f();
}
expect: {
function f() {
(function() {
switch (0) {
default:
case console.log("PASS"):
}
})();
}
f();
}
expect_stdout: "PASS"
}