Don't directly produce errors while parsing 'try' statements.

This commit is contained in:
Cyrus Najmabadi
2014-12-01 00:16:55 -08:00
parent f404212793
commit 7eb4e742d1
3 changed files with 5 additions and 9 deletions

View File

@@ -3397,12 +3397,13 @@ module ts {
if (token === SyntaxKind.CatchKeyword) {
node.catchBlock = parseCatchBlock();
}
if (token === SyntaxKind.FinallyKeyword) {
// If we don't have a catch clause, then we must have a finally clause. Try to parse
// one out no matter what.
if (!node.catchBlock || token === SyntaxKind.FinallyKeyword) {
node.finallyBlock = parseTokenAndBlock(SyntaxKind.FinallyKeyword, SyntaxKind.FinallyBlock);
}
if (!(node.catchBlock || node.finallyBlock)) {
error(Diagnostics.catch_or_finally_expected);
}
return finishNode(node);
}