Skip to content

Commit

Permalink
Do not truncate after switch-statement with removed case (#3241)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Nov 18, 2019
1 parent 3885a7f commit 690d388
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ast/nodes/SwitchStatement.ts
Expand Up @@ -65,6 +65,8 @@ export default class SwitchStatement extends StatementBase {
switchCase.include(context, includeChildrenRecursively);
minBrokenFlow = minBrokenFlow < context.brokenFlow ? minBrokenFlow : context.brokenFlow;
context.brokenFlow = brokenFlow;
} else {
minBrokenFlow = brokenFlow;
}
}
if (
Expand Down
@@ -0,0 +1,3 @@
module.exports = {
description: 'does not remove code after a switch statement that should be retained'
};
10 changes: 10 additions & 0 deletions test/function/samples/switch-statements-removed-default/main.js
@@ -0,0 +1,10 @@
function performSwitch(value) {
switch (value) {
case 'foo':
return false;
default:
}
return true;
}

assert.ok(performSwitch('baz'));

0 comments on commit 690d388

Please sign in to comment.