fallthrough should not execute case expression
Also enable switch statement fuzzing. fixes #1680
This commit is contained in:
parent
94f84727ce
commit
4ce5c784d6
|
|
@ -2562,11 +2562,6 @@ merge(Compressor.prototype, {
|
|||
}
|
||||
for (; i < len && fallthrough; i++) {
|
||||
branch = self.body[i];
|
||||
if (branch instanceof AST_Case) {
|
||||
exact_match.body.push(make_node(AST_SimpleStatement, branch.expression, {
|
||||
body: branch.expression
|
||||
}));
|
||||
}
|
||||
exact_match.body = exact_match.body.concat(branch.body);
|
||||
fallthrough = !aborts(exact_match);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ constant_switch_2: {
|
|||
}
|
||||
expect: {
|
||||
foo();
|
||||
2;
|
||||
bar();
|
||||
}
|
||||
}
|
||||
|
|
@ -118,7 +117,6 @@ constant_switch_6: {
|
|||
x();
|
||||
if (foo) break OUT;
|
||||
y();
|
||||
2;
|
||||
bar();
|
||||
}
|
||||
}
|
||||
|
|
@ -157,7 +155,6 @@ constant_switch_7: {
|
|||
console.log(x);
|
||||
}
|
||||
y();
|
||||
2;
|
||||
bar();
|
||||
}
|
||||
}
|
||||
|
|
@ -206,7 +203,6 @@ constant_switch_9: {
|
|||
x();
|
||||
for (;;) if (foo) break OUT;
|
||||
y();
|
||||
2;
|
||||
bar();
|
||||
def();
|
||||
}
|
||||
|
|
@ -481,3 +477,44 @@ issue_1679: {
|
|||
}
|
||||
expect_stdout: true
|
||||
}
|
||||
|
||||
issue_1680: {
|
||||
options = {
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
}
|
||||
input: {
|
||||
function f(x) {
|
||||
console.log(x);
|
||||
return x + 1;
|
||||
}
|
||||
switch (2) {
|
||||
case f(0):
|
||||
case f(1):
|
||||
f(2);
|
||||
case 2:
|
||||
case f(3):
|
||||
case f(4):
|
||||
f(5);
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
function f(x) {
|
||||
console.log(x);
|
||||
return x + 1;
|
||||
}
|
||||
switch (2) {
|
||||
case f(0):
|
||||
case f(1):
|
||||
f(2);
|
||||
case 2:
|
||||
f(5);
|
||||
}
|
||||
}
|
||||
expect_stdout: [
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"5",
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,7 +201,6 @@ function createStatement(recurmax, canThrow, canBreak, canContinue) {
|
|||
case 6:
|
||||
return createExpression(recurmax) + ';';
|
||||
case 7:
|
||||
return ';'; // TODO: disabled until some switch issues are resolved
|
||||
// note: case args are actual expressions
|
||||
// note: default does not _need_ to be last
|
||||
return 'switch (' + createExpression(recurmax) + ') { ' + createSwitchParts(recurmax, 4) + '}';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user