check that default clause is non-empty in reachability checks

This commit is contained in:
Vladimir Matveev
2016-05-27 15:38:59 -07:00
parent f07b4ba9d7
commit 92938cd8df
5 changed files with 68 additions and 2 deletions

View File

@@ -912,8 +912,8 @@ namespace ts {
preSwitchCaseFlow = currentFlow;
bind(node.caseBlock);
addAntecedent(postSwitchLabel, currentFlow);
const hasDefault = forEach(node.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause);
if (!hasDefault) {
const hasNonEmptyDefault = forEach(node.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause && c.statements.length);
if (!hasNonEmptyDefault) {
addAntecedent(postSwitchLabel, preSwitchCaseFlow);
}
currentBreakTarget = saveBreakTarget;