mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Move grammar checking: bindingElement
This commit is contained in:
+15
-1
@@ -7895,6 +7895,12 @@ module ts {
|
||||
|
||||
// Check variable, parameter, or property declaration
|
||||
function checkVariableLikeDeclaration(node: VariableLikeDeclaration) {
|
||||
// Grammar checking
|
||||
// TODO (yuisu) : Revisit this check once move all grammar checking
|
||||
if (node.kind === SyntaxKind.BindingElement) {
|
||||
checkGrammarBindingElement(<BindingElement>node);
|
||||
}
|
||||
|
||||
checkSourceElement(node.type);
|
||||
// For a computed property, just check the initializer and exit
|
||||
if (hasComputedNameButNotSymbol(node)) {
|
||||
@@ -9761,7 +9767,7 @@ module ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
// TODO (yuisu) : Bring back the parser grammar checking
|
||||
// TODO (yuisu) : Revisit this once moving ambient Context into type checking
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -9925,6 +9931,14 @@ module ts {
|
||||
checkGrammarForOmittedArgument(node, arguments);
|
||||
}
|
||||
|
||||
function checkGrammarBindingElement(node: BindingElement) {
|
||||
if (!checkGrammarModifiers(node) && (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.name))) {
|
||||
// It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code
|
||||
// and its Identifier is eval or arguments
|
||||
reportGrammarErrorOfInvalidUseInStrictMode(<Identifier>node.name);
|
||||
}
|
||||
}
|
||||
|
||||
function hasParseDiagnostics(sourceFile: SourceFile): boolean {
|
||||
return sourceFile.parseDiagnostics.length > 0;
|
||||
}
|
||||
|
||||
@@ -4635,7 +4635,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.BindingElement: return checkBindingElement(<BindingElement>node);
|
||||
case SyntaxKind.CatchClause: return checkCatchClause(<CatchClause>node);
|
||||
case SyntaxKind.ClassDeclaration: return checkClassDeclaration(<ClassDeclaration>node);
|
||||
case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(<ComputedPropertyName>node);
|
||||
|
||||
Reference in New Issue
Block a user