fix corner cases in switch and undefined (#1762)

- fix side effects in switch condition for singular blocks
- fix `undefined` confusion with local variable
- gate `OPT(AST_Switch)` with `switches`

fixes #1758
fixes #1759
This commit is contained in:
Alex Lam S.L
2017-04-02 14:52:25 +08:00
committed by GitHub
parent c076e7b60d
commit f7ca4f2297
5 changed files with 159 additions and 15 deletions

View File

@@ -440,3 +440,29 @@ func_def_5: {
}
expect_stdout: "true"
}
issue_1758: {
options = {
sequences: true,
side_effects: true,
}
input: {
console.log(function(c) {
var undefined = 42;
return function() {
c--;
c--, c.toString();
return;
}();
}());
}
expect: {
console.log(function(c) {
var undefined = 42;
return function() {
return c--, c--, c.toString(), void 0;
}();
}());
}
expect_stdout: "undefined"
}