diff --git a/src/ast/nodes/SwitchStatement.ts b/src/ast/nodes/SwitchStatement.ts index 7939b8ac0b0..2850b18f122 100644 --- a/src/ast/nodes/SwitchStatement.ts +++ b/src/ast/nodes/SwitchStatement.ts @@ -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 ( diff --git a/test/function/samples/switch-statements-removed-default/_config.js b/test/function/samples/switch-statements-removed-default/_config.js new file mode 100644 index 00000000000..2c58f54526d --- /dev/null +++ b/test/function/samples/switch-statements-removed-default/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'does not remove code after a switch statement that should be retained' +}; diff --git a/test/function/samples/switch-statements-removed-default/main.js b/test/function/samples/switch-statements-removed-default/main.js new file mode 100644 index 00000000000..034104555ba --- /dev/null +++ b/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'));