mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Move grammar checking: catchCaluse
This commit is contained in:
+18
-1
@@ -8095,7 +8095,11 @@ module ts {
|
||||
|
||||
function checkTryStatement(node: TryStatement) {
|
||||
checkBlock(node.tryBlock);
|
||||
if (node.catchClause) checkBlock(node.catchClause.block);
|
||||
if (node.catchClause) {
|
||||
// Grammar checking
|
||||
checkGrammarCatchClause(node.catchClause);
|
||||
checkBlock(node.catchClause.block);
|
||||
}
|
||||
if (node.finallyBlock) checkBlock(node.finallyBlock);
|
||||
}
|
||||
|
||||
@@ -9939,6 +9943,19 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkGrammarCatchClause(node: CatchClause) {
|
||||
if (node.type) {
|
||||
var sourceFile = getSourceFileOfNode(node);
|
||||
var colonStart = skipTrivia(sourceFile.text, node.name.end);
|
||||
grammarErrorAtPos(sourceFile, colonStart, ":".length, Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation);
|
||||
}
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.name)) {
|
||||
// It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the
|
||||
// Catch production is eval or arguments
|
||||
reportGrammarErrorOfInvalidUseInStrictMode(node.name);
|
||||
}
|
||||
}
|
||||
|
||||
function hasParseDiagnostics(sourceFile: SourceFile): boolean {
|
||||
return sourceFile.parseDiagnostics.length > 0;
|
||||
}
|
||||
|
||||
@@ -4636,7 +4636,7 @@ module ts {
|
||||
case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(<EnumDeclaration>node);
|
||||
//case SyntaxKind.BinaryExpression: return checkBinaryExpression(<BinaryExpression>node);
|
||||
//case SyntaxKind.BindingElement: return checkBindingElement(<BindingElement>node);
|
||||
case SyntaxKind.CatchClause: return checkCatchClause(<CatchClause>node);
|
||||
//case SyntaxKind.CatchClause: return checkCatchClause(<CatchClause>node);
|
||||
case SyntaxKind.ClassDeclaration: return checkClassDeclaration(<ClassDeclaration>node);
|
||||
case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(<ComputedPropertyName>node);
|
||||
case SyntaxKind.Constructor: return checkConstructor(<ConstructorDeclaration>node);
|
||||
|
||||
Reference in New Issue
Block a user