Move type checking: elementAccessExpression; there are still errors from not moving other grammar checking into type checker

This commit is contained in:
Yui T
2014-12-12 13:16:19 -08:00
parent 90e1d4244f
commit afc04c8db8
12 changed files with 63 additions and 48 deletions
+15
View File
@@ -5555,6 +5555,21 @@ module ts {
}
function checkIndexedAccess(node: ElementAccessExpression): Type {
// Grammar checking
if (!node.argumentExpression) {
var sourceFile = getSourceFile(node);
if (node.parent.kind === SyntaxKind.NewExpression && (<NewExpression>node.parent).expression === node) {
var start = skipTrivia(sourceFile.text, node.expression.end);
var end = node.end;
grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead);
}
else {
var start = node.end - "]".length;
var end = node.end;
grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Expression_expected);
}
}
// Obtain base constraint such that we can bail out if the constraint is an unknown type
var objectType = getApparentType(checkExpression(node.expression));
var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType;
+1 -1
View File
@@ -4641,7 +4641,7 @@ module ts {
//case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(<ComputedPropertyName>node);
case SyntaxKind.Constructor: return checkConstructor(<ConstructorDeclaration>node);
//case SyntaxKind.DeleteExpression: return checkDeleteExpression(<DeleteExpression> node);
case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(<ElementAccessExpression>node);
//case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(<ElementAccessExpression>node);
case SyntaxKind.ExportAssignment: return checkExportAssignment(<ExportAssignment>node);
case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(<ExternalModuleReference>node);
case SyntaxKind.ForInStatement: return checkForInStatement(<ForInStatement>node);