Move grammar checking: bindingElement

This commit is contained in:
Yui T
2014-12-11 14:35:55 -08:00
parent 0d99f1afd5
commit b34a453cd4
2 changed files with 16 additions and 2 deletions
+15 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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);