Move grammar checking: forInStatement; there are still errors from incomplete migration
This commit is contained in:
parent
e0e88adfc5
commit
010745c371
6 changed files with 17 additions and 9 deletions
|
@ -8097,6 +8097,14 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkForInStatement(node: ForInStatement) {
|
function checkForInStatement(node: ForInStatement) {
|
||||||
|
// Grammar checking
|
||||||
|
var declarations = node.declarations;
|
||||||
|
if (!checkGrammarVariableDeclarations(node, declarations)) {
|
||||||
|
if (declarations && declarations.length > 1) {
|
||||||
|
grammarErrorOnFirstToken(declarations[1], Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TypeScript 1.0 spec (April 2014): 5.4
|
// TypeScript 1.0 spec (April 2014): 5.4
|
||||||
// In a 'for-in' statement of the form
|
// In a 'for-in' statement of the form
|
||||||
// for (var VarDecl in Expr) Statement
|
// for (var VarDecl in Expr) Statement
|
||||||
|
@ -10411,14 +10419,14 @@ module ts {
|
||||||
return checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>node.name);
|
return checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>node.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkGrammarVariableDeclarations(variableStatement: VariableStatement, declarations: NodeArray<VariableDeclaration>): boolean {
|
function checkGrammarVariableDeclarations(container: Node, declarations: NodeArray<VariableDeclaration>): boolean {
|
||||||
if (declarations) {
|
if (declarations) {
|
||||||
if (checkGrammarForDisallowedTrailingComma(declarations)) {
|
if (checkGrammarForDisallowedTrailingComma(declarations)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!declarations.length) {
|
if (!declarations.length) {
|
||||||
return grammarErrorAtPos(getSourceFileOfNode(variableStatement), declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty);
|
return grammarErrorAtPos(getSourceFileOfNode(container), declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
var decl = declarations[0];
|
var decl = declarations[0];
|
||||||
|
|
|
@ -4644,7 +4644,7 @@ module ts {
|
||||||
//case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(<ElementAccessExpression>node);
|
//case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(<ElementAccessExpression>node);
|
||||||
//case SyntaxKind.ExportAssignment: return checkExportAssignment(<ExportAssignment>node);
|
//case SyntaxKind.ExportAssignment: return checkExportAssignment(<ExportAssignment>node);
|
||||||
//case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(<ExternalModuleReference>node);
|
//case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(<ExternalModuleReference>node);
|
||||||
case SyntaxKind.ForInStatement: return checkForInStatement(<ForInStatement>node);
|
//case SyntaxKind.ForInStatement: return checkForInStatement(<ForInStatement>node);
|
||||||
case SyntaxKind.ForStatement: return checkForStatement(<ForStatement>node);
|
case SyntaxKind.ForStatement: return checkForStatement(<ForStatement>node);
|
||||||
case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(<FunctionLikeDeclaration>node);
|
case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(<FunctionLikeDeclaration>node);
|
||||||
//case SyntaxKind.FunctionExpression: return checkFunctionExpression(<FunctionExpression>node);
|
//case SyntaxKind.FunctionExpression: return checkFunctionExpression(<FunctionExpression>node);
|
||||||
|
|
|
@ -5,9 +5,9 @@ tests/cases/compiler/constDeclarations-errors.ts(5,11): error TS1155: 'const' de
|
||||||
tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: 'const' declarations must be initialized
|
tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: 'const' declarations must be initialized
|
||||||
tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: 'const' declarations must be initialized
|
tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: 'const' declarations must be initialized
|
||||||
tests/cases/compiler/constDeclarations-errors.ts(8,11): error TS1155: 'const' declarations must be initialized
|
tests/cases/compiler/constDeclarations-errors.ts(8,11): error TS1155: 'const' declarations must be initialized
|
||||||
|
tests/cases/compiler/constDeclarations-errors.ts(11,27): error TS2449: The operand of an increment or decrement operator cannot be a constant.
|
||||||
tests/cases/compiler/constDeclarations-errors.ts(14,11): error TS1155: 'const' declarations must be initialized
|
tests/cases/compiler/constDeclarations-errors.ts(14,11): error TS1155: 'const' declarations must be initialized
|
||||||
tests/cases/compiler/constDeclarations-errors.ts(17,20): error TS1155: 'const' declarations must be initialized
|
tests/cases/compiler/constDeclarations-errors.ts(17,20): error TS1155: 'const' declarations must be initialized
|
||||||
tests/cases/compiler/constDeclarations-errors.ts(11,27): error TS2449: The operand of an increment or decrement operator cannot be a constant.
|
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/constDeclarations-errors.ts (10 errors) ====
|
==== tests/cases/compiler/constDeclarations-errors.ts (10 errors) ====
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
tests/cases/compiler/declareAlreadySeen.ts(2,13): error TS1030: 'declare' modifier already seen.
|
|
||||||
tests/cases/compiler/declareAlreadySeen.ts(3,13): error TS1030: 'declare' modifier already seen.
|
tests/cases/compiler/declareAlreadySeen.ts(3,13): error TS1030: 'declare' modifier already seen.
|
||||||
tests/cases/compiler/declareAlreadySeen.ts(5,13): error TS1030: 'declare' modifier already seen.
|
tests/cases/compiler/declareAlreadySeen.ts(5,13): error TS1030: 'declare' modifier already seen.
|
||||||
|
tests/cases/compiler/declareAlreadySeen.ts(2,13): error TS1030: 'declare' modifier already seen.
|
||||||
tests/cases/compiler/declareAlreadySeen.ts(7,13): error TS1030: 'declare' modifier already seen.
|
tests/cases/compiler/declareAlreadySeen.ts(7,13): error TS1030: 'declare' modifier already seen.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(10,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(12,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(12,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(2,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(2,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(3,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(3,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
@ -6,6 +5,7 @@ tests/cases/compiler/letDeclarations-es5.ts(4,5): error TS1153: 'let' declaratio
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(6,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(6,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(7,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(7,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
tests/cases/compiler/letDeclarations-es5.ts(8,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
tests/cases/compiler/letDeclarations-es5.ts(8,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
tests/cases/compiler/letDeclarations-es5.ts(10,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/letDeclarations-es5.ts (8 errors) ====
|
==== tests/cases/compiler/letDeclarations-es5.ts (8 errors) ====
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement7.ts(1,25): error TS1091: Only a single variable declaration is allowed in a 'for...in' statement.
|
|
||||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement7.ts(1,10): error TS2404: The left-hand side of a 'for...in' statement cannot use a type annotation.
|
tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement7.ts(1,10): error TS2404: The left-hand side of a 'for...in' statement cannot use a type annotation.
|
||||||
|
tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement7.ts(1,25): error TS1091: Only a single variable declaration is allowed in a 'for...in' statement.
|
||||||
tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement7.ts(1,43): error TS2304: Cannot find name 'X'.
|
tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement7.ts(1,43): error TS2304: Cannot find name 'X'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement7.ts (3 errors) ====
|
==== tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement7.ts (3 errors) ====
|
||||||
for (var a: number = 1, b: string = "" in X) {
|
for (var a: number = 1, b: string = "" in X) {
|
||||||
~
|
~
|
||||||
!!! error TS1091: Only a single variable declaration is allowed in a 'for...in' statement.
|
|
||||||
~
|
|
||||||
!!! error TS2404: The left-hand side of a 'for...in' statement cannot use a type annotation.
|
!!! error TS2404: The left-hand side of a 'for...in' statement cannot use a type annotation.
|
||||||
~
|
~
|
||||||
|
!!! error TS1091: Only a single variable declaration is allowed in a 'for...in' statement.
|
||||||
|
~
|
||||||
!!! error TS2304: Cannot find name 'X'.
|
!!! error TS2304: Cannot find name 'X'.
|
||||||
}
|
}
|
Loading…
Reference in a new issue