From 2c575dae27421f3e67cd4d33995ca630a2b992b0 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 9 Dec 2014 16:33:20 -0800 Subject: [PATCH 01/74] Move grammar checking: type parameters --- src/compiler/checker.ts | 50 ++++++++++++++++++- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 +- src/compiler/parser.ts | 7 --- .../typeParameterConstraints1.errors.txt | 2 +- 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c383368df2..d3d4ae2088e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -164,6 +164,13 @@ module ts { var diagnostics: Diagnostic[] = []; var diagnosticsModified: boolean = false; + // Grammar checking + var sourceText: string = undefined; + var scanner: Scanner = undefined; + var hasParserError: boolean; + var grammarDiagnostics: Diagnostic[]; + var sourceFile: SourceFile; + function addDiagnostic(diagnostic: Diagnostic) { diagnostics.push(diagnostic); diagnosticsModified = true; @@ -7017,6 +7024,11 @@ module ts { // DECLARATION AND STATEMENT TYPE CHECKING function checkTypeParameter(node: TypeParameterDeclaration) { + // Grammar Checking + if (!hasParserError && node.expression) { + grammarErrorOnFirstToken(node.expression, Diagnostics.Type_expected); + } + checkSourceElement(node.constraint); if (fullTypeCheck) { checkTypeParameterHasIllegalReferencesInConstraint(node); @@ -8655,6 +8667,36 @@ module ts { return node; } + // Grammar checking helper functions + function scanToken(pos: number) { + var start = skipTrivia(sourceText, pos); + scanner.setTextPos(start); + scanner.scan(); + return start; + } + + function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + var start = scanToken(node.pos); + diagnostics.push(createFileDiagnostic(sourceFile, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); + } + + function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + scanToken(node.pos); + diagnostics.push(createFileDiagnostic(sourceFile, scanner.getTextPos(), 0, message, arg0, arg1, arg2)); + } + + function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + var span = getErrorSpanForNode(node); + var start = span.end > span.pos ? skipTrivia(sourceFile.text, span.pos) : span.pos; + var length = span.end - start; + + diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); + } + + function grammarErrorAtPos(start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); + } + function checkImportDeclaration(node: ImportDeclaration) { checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -8909,6 +8951,12 @@ module ts { // Fully type check a source file and collect the relevant diagnostics. function checkSourceFile(node: SourceFile) { + sourceText = node.text; + scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceText); + hasParserError = node.parseDiagnostics.length > 0 ? true : false; + sourceFile = node; + //grammarDiagnostics = []; + var links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { emitExtends = false; @@ -9469,7 +9517,7 @@ module ts { return program.getDiagnostics(sourceFile).length !== 0 || hasEarlyErrors(sourceFile) || (compilerOptions.noEmitOnError && getDiagnostics(sourceFile).length !== 0); - } + } function hasEarlyErrors(sourceFile?: SourceFile): boolean { return forEach(getDiagnostics(sourceFile), d => d.isEarly); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 17dbae83bf2..5f54befb89b 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -73,7 +73,7 @@ module ts { Jump_target_cannot_cross_function_boundary: { code: 1107, category: DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." }, A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." }, Expression_expected: { code: 1109, category: DiagnosticCategory.Error, key: "Expression expected." }, - Type_expected: { code: 1110, category: DiagnosticCategory.Error, key: "Type expected." }, + Type_expected: { code: 1110, category: DiagnosticCategory.Error, key: "Type expected.", isEarly: true }, A_constructor_implementation_cannot_be_declared_in_an_ambient_context: { code: 1111, category: DiagnosticCategory.Error, key: "A constructor implementation cannot be declared in an ambient context." }, A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a06b71d460e..f694ccfc32f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -285,7 +285,8 @@ }, "Type expected.": { "category": "Error", - "code": 1110 + "code": 1110, + "isEarly": true }, "A constructor implementation cannot be declared in an ambient context.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d406b938d4e..58582964550 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4679,7 +4679,6 @@ module ts { case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); case SyntaxKind.ThrowStatement: return checkThrowStatement(node); case SyntaxKind.TupleType: return checkTupleType(node); - case SyntaxKind.TypeParameter: return checkTypeParameter(node); case SyntaxKind.TypeReference: return checkTypeReference(node); case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); case SyntaxKind.VariableStatement: return checkVariableStatement(node); @@ -5727,12 +5726,6 @@ module ts { } } - function checkTypeParameter(node: TypeParameterDeclaration) { - if (node.expression) { - return grammarErrorOnFirstToken(node.expression, Diagnostics.Type_expected); - } - } - function checkTypeReference(node: TypeReferenceNode) { return checkTypeArguments(node.typeArguments); } diff --git a/tests/baselines/reference/typeParameterConstraints1.errors.txt b/tests/baselines/reference/typeParameterConstraints1.errors.txt index d2e1f505c83..f30fd4f6700 100644 --- a/tests/baselines/reference/typeParameterConstraints1.errors.txt +++ b/tests/baselines/reference/typeParameterConstraints1.errors.txt @@ -1,8 +1,8 @@ +tests/cases/compiler/typeParameterConstraints1.ts(6,25): error TS2304: Cannot find name 'hm'. tests/cases/compiler/typeParameterConstraints1.ts(8,25): error TS1110: Type expected. tests/cases/compiler/typeParameterConstraints1.ts(9,25): error TS1110: Type expected. tests/cases/compiler/typeParameterConstraints1.ts(10,26): error TS1110: Type expected. tests/cases/compiler/typeParameterConstraints1.ts(11,26): error TS1110: Type expected. -tests/cases/compiler/typeParameterConstraints1.ts(6,25): error TS2304: Cannot find name 'hm'. tests/cases/compiler/typeParameterConstraints1.ts(12,26): error TS2304: Cannot find name 'undefined'. From 949be0597fce1873c7dabe3584220f8a82d8f28d Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 9 Dec 2014 16:33:20 -0800 Subject: [PATCH 02/74] Move grammar checking: type parameters --- src/compiler/checker.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d3d4ae2088e..59481783661 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -168,7 +168,6 @@ module ts { var sourceText: string = undefined; var scanner: Scanner = undefined; var hasParserError: boolean; - var grammarDiagnostics: Diagnostic[]; var sourceFile: SourceFile; function addDiagnostic(diagnostic: Diagnostic) { @@ -8955,7 +8954,6 @@ module ts { scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceText); hasParserError = node.parseDiagnostics.length > 0 ? true : false; sourceFile = node; - //grammarDiagnostics = []; var links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { From afcf11545c7b24826322e01381737bcd58ff7af8 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 9 Dec 2014 16:33:20 -0800 Subject: [PATCH 03/74] Move grammar checking: type parameters --- src/compiler/checker.ts | 34 +++---------------- .../typeParameterConstraints1.errors.txt | 2 +- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d3d4ae2088e..d676b5faeaa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -168,7 +168,6 @@ module ts { var sourceText: string = undefined; var scanner: Scanner = undefined; var hasParserError: boolean; - var grammarDiagnostics: Diagnostic[]; var sourceFile: SourceFile; function addDiagnostic(diagnostic: Diagnostic) { @@ -7026,7 +7025,8 @@ module ts { function checkTypeParameter(node: TypeParameterDeclaration) { // Grammar Checking if (!hasParserError && node.expression) { - grammarErrorOnFirstToken(node.expression, Diagnostics.Type_expected); + var sourceFile = getSourceFileOfNode(node); + grammarErrorOnNode(sourceFile, node.expression, Diagnostics.Type_expected); } checkSourceElement(node.constraint); @@ -8668,32 +8668,9 @@ module ts { } // Grammar checking helper functions - function scanToken(pos: number) { - var start = skipTrivia(sourceText, pos); - scanner.setTextPos(start); - scanner.scan(); - return start; - } - - function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { - var start = scanToken(node.pos); - diagnostics.push(createFileDiagnostic(sourceFile, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); - } - - function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { - scanToken(node.pos); - diagnostics.push(createFileDiagnostic(sourceFile, scanner.getTextPos(), 0, message, arg0, arg1, arg2)); - } - - function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { - var span = getErrorSpanForNode(node); - var start = span.end > span.pos ? skipTrivia(sourceFile.text, span.pos) : span.pos; - var length = span.end - start; - - diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); - } - - function grammarErrorAtPos(start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + function grammarErrorOnNode(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + var start = getFullWidth(node) === 0 ? node.pos : skipTrivia(sourceFile.text, node.pos); + var length = node.end - start; diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); } @@ -8955,7 +8932,6 @@ module ts { scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceText); hasParserError = node.parseDiagnostics.length > 0 ? true : false; sourceFile = node; - //grammarDiagnostics = []; var links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { diff --git a/tests/baselines/reference/typeParameterConstraints1.errors.txt b/tests/baselines/reference/typeParameterConstraints1.errors.txt index f30fd4f6700..44261e8d194 100644 --- a/tests/baselines/reference/typeParameterConstraints1.errors.txt +++ b/tests/baselines/reference/typeParameterConstraints1.errors.txt @@ -23,7 +23,7 @@ tests/cases/compiler/typeParameterConstraints1.ts(12,26): error TS2304: Cannot f ~ !!! error TS1110: Type expected. function foo10 (test: T) { } - ~ + ~~~ !!! error TS1110: Type expected. function foo11 (test: T) { } ~~~~ From 6a4d50d025f4ad7a7c7668c5de2c7d12a5bf806a Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 9 Dec 2014 18:32:56 -0800 Subject: [PATCH 04/74] Address code review for moving grammar check of typeParameter --- src/compiler/checker.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d676b5faeaa..1e831600d7c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -164,12 +164,6 @@ module ts { var diagnostics: Diagnostic[] = []; var diagnosticsModified: boolean = false; - // Grammar checking - var sourceText: string = undefined; - var scanner: Scanner = undefined; - var hasParserError: boolean; - var sourceFile: SourceFile; - function addDiagnostic(diagnostic: Diagnostic) { diagnostics.push(diagnostic); diagnosticsModified = true; @@ -7024,8 +7018,8 @@ module ts { function checkTypeParameter(node: TypeParameterDeclaration) { // Grammar Checking - if (!hasParserError && node.expression) { - var sourceFile = getSourceFileOfNode(node); + var sourceFile = getSourceFileOfNode(node); + if (node.expression && !hasParseDiagnostics(sourceFile)) { grammarErrorOnNode(sourceFile, node.expression, Diagnostics.Type_expected); } @@ -8668,6 +8662,10 @@ module ts { } // Grammar checking helper functions + function hasParseDiagnostics(sourceFile: SourceFile): boolean { + return sourceFile.parseDiagnostics.length > 0 ? true : false; + } + function grammarErrorOnNode(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { var start = getFullWidth(node) === 0 ? node.pos : skipTrivia(sourceFile.text, node.pos); var length = node.end - start; @@ -8928,11 +8926,6 @@ module ts { // Fully type check a source file and collect the relevant diagnostics. function checkSourceFile(node: SourceFile) { - sourceText = node.text; - scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceText); - hasParserError = node.parseDiagnostics.length > 0 ? true : false; - sourceFile = node; - var links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { emitExtends = false; From a94c51faee363345e28c8afbdd0ee0d4f7a76dbe Mon Sep 17 00:00:00 2001 From: yui T Date: Wed, 10 Dec 2014 11:26:24 -0800 Subject: [PATCH 05/74] Address code review for moving grammar check of typeParameter --- src/compiler/checker.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1e831600d7c..2ad07454a90 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7018,9 +7018,9 @@ module ts { function checkTypeParameter(node: TypeParameterDeclaration) { // Grammar Checking - var sourceFile = getSourceFileOfNode(node); - if (node.expression && !hasParseDiagnostics(sourceFile)) { - grammarErrorOnNode(sourceFile, node.expression, Diagnostics.Type_expected); + if (node.expression) { + var sourceFile = getSourceFileOfNode(node); + grammarErrorOnFirstToken(sourceFile, node.expression, Diagnostics.Type_expected); } checkSourceElement(node.constraint); @@ -8666,10 +8666,12 @@ module ts { return sourceFile.parseDiagnostics.length > 0 ? true : false; } - function grammarErrorOnNode(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { - var start = getFullWidth(node) === 0 ? node.pos : skipTrivia(sourceFile.text, node.pos); - var length = node.end - start; - diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); + function grammarErrorOnFirstToken(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + if (!hasParseDiagnostics(sourceFile)) { + var start = skipTrivia(sourceFile.text, node.pos); + var length = node.end - start; + diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); + } } function checkImportDeclaration(node: ImportDeclaration) { From 03f9203a42995ce35b02d1c57975e56b3307e6b6 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 10 Dec 2014 12:42:34 -0800 Subject: [PATCH 06/74] Move grammar checking: tuple type --- src/compiler/checker.ts | 32 +++++++++++++++++-- .../diagnosticInformationMap.generated.ts | 4 +-- src/compiler/diagnosticMessages.json | 6 ++-- src/compiler/parser.ts | 2 +- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2ad07454a90..fd79e04ad2e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7274,6 +7274,13 @@ module ts { } function checkTupleType(node: TupleTypeNode) { + // Grammar checking + var sourceFile = getSourceFileOfNode(node); + checkGrammarForDisallowedTrailingComma(sourceFile, node.elementTypes); + if (node.elementTypes.length === 0) { + grammarErrorOnNode(sourceFile, node, Diagnostics.A_tuple_type_element_list_cannot_be_empty); + } + forEach(node.elementTypes, checkSourceElement); } @@ -8661,7 +8668,15 @@ module ts { return node; } - // Grammar checking helper functions + // GRAMMAR CHECKING + function checkGrammarForDisallowedTrailingComma(sourceFile: SourceFile, list: NodeArray): void { + if (list && list.hasTrailingComma) { + var start = list.end - ",".length; + var end = list.end; + grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Trailing_comma_not_allowed); + } + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0 ? true : false; } @@ -8669,11 +8684,24 @@ module ts { function grammarErrorOnFirstToken(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { if (!hasParseDiagnostics(sourceFile)) { var start = skipTrivia(sourceFile.text, node.pos); - var length = node.end - start; + diagnostics.push(createFileDiagnostic(sourceFile, start, node.end - start, message, arg0, arg1, arg2)); + } + } + + function grammarErrorAtPos(sourceFile: SourceFile, start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + if (!hasParseDiagnostics(sourceFile)) { diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); } } + function grammarErrorOnNode(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + if (!hasParseDiagnostics(sourceFile)) { + var span = getErrorSpanForNode(node); + var start = span.end > span.pos ? skipTrivia(sourceFile.text, span.pos) : span.pos; + diagnostics.push(createFileDiagnostic(sourceFile, start, span.end - start, message, arg0, arg1, arg2)); + } + } + function checkImportDeclaration(node: ImportDeclaration) { checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 5f54befb89b..795dc31d09c 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -6,7 +6,7 @@ module ts { Identifier_expected: { code: 1003, category: DiagnosticCategory.Error, key: "Identifier expected." }, _0_expected: { code: 1005, category: DiagnosticCategory.Error, key: "'{0}' expected." }, A_file_cannot_have_a_reference_to_itself: { code: 1006, category: DiagnosticCategory.Error, key: "A file cannot have a reference to itself." }, - Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed." }, + Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed.", isEarly: true }, Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." }, Unexpected_token: { code: 1012, category: DiagnosticCategory.Error, key: "Unexpected token." }, Catch_clause_parameter_cannot_have_a_type_annotation: { code: 1013, category: DiagnosticCategory.Error, key: "Catch clause parameter cannot have a type annotation." }, @@ -85,7 +85,7 @@ module ts { An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, An_export_assignment_cannot_have_modifiers: { code: 1120, category: DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." }, Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." }, - A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: DiagnosticCategory.Error, key: "A tuple type element list cannot be empty." }, + A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: DiagnosticCategory.Error, key: "A tuple type element list cannot be empty.", isEarly: true }, Variable_declaration_list_cannot_be_empty: { code: 1123, category: DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." }, Digit_expected: { code: 1124, category: DiagnosticCategory.Error, key: "Digit expected." }, Hexadecimal_digit_expected: { code: 1125, category: DiagnosticCategory.Error, key: "Hexadecimal digit expected." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f694ccfc32f..f3fc9b9b715 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -17,7 +17,8 @@ }, "Trailing comma not allowed.": { "category": "Error", - "code": 1009 + "code": 1009, + "isEarly": true }, "'*/' expected.": { "category": "Error", @@ -334,7 +335,8 @@ }, "A tuple type element list cannot be empty.": { "category": "Error", - "code": 1122 + "code": 1122, + "isEarly": true }, "Variable declaration list cannot be empty.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 58582964550..5b2b8ad0dad 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4678,7 +4678,7 @@ module ts { case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); case SyntaxKind.ThrowStatement: return checkThrowStatement(node); - case SyntaxKind.TupleType: return checkTupleType(node); + //case SyntaxKind.TupleType: return checkTupleType(node); case SyntaxKind.TypeReference: return checkTypeReference(node); case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); case SyntaxKind.VariableStatement: return checkVariableStatement(node); From 073994ec5526b112c10ccdee6a3a02778415c40e Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 10 Dec 2014 15:44:36 -0800 Subject: [PATCH 07/74] Addres code review --- src/compiler/binder.ts | 3 +++ src/compiler/checker.ts | 35 ++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index dfb5482b09c..a458779e52f 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -387,6 +387,9 @@ module ts { switch (node.kind) { case SyntaxKind.TypeParameter: bindDeclaration(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false); + if ((node).expression) { + (node).expression.parent = node; + } break; case SyntaxKind.Parameter: if (isBindingPattern((node).name)) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fd79e04ad2e..f8280ffd230 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7020,7 +7020,7 @@ module ts { // Grammar Checking if (node.expression) { var sourceFile = getSourceFileOfNode(node); - grammarErrorOnFirstToken(sourceFile, node.expression, Diagnostics.Type_expected); + grammarErrorOnFirstToken(node.expression, Diagnostics.Type_expected); } checkSourceElement(node.constraint); @@ -7275,10 +7275,9 @@ module ts { function checkTupleType(node: TupleTypeNode) { // Grammar checking - var sourceFile = getSourceFileOfNode(node); - checkGrammarForDisallowedTrailingComma(sourceFile, node.elementTypes); - if (node.elementTypes.length === 0) { - grammarErrorOnNode(sourceFile, node, Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); + if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { + grammarErrorOnNode(node, Diagnostics.A_tuple_type_element_list_cannot_be_empty); } forEach(node.elementTypes, checkSourceElement); @@ -8669,22 +8668,35 @@ module ts { } // GRAMMAR CHECKING - function checkGrammarForDisallowedTrailingComma(sourceFile: SourceFile, list: NodeArray): void { + function checkGrammarForDisallowedTrailingComma(list: NodeArray): boolean { if (list && list.hasTrailingComma) { var start = list.end - ",".length; var end = list.end; + var sourceFile = getSourceFileOfNode(list[0]); grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Trailing_comma_not_allowed); + return true; } } function hasParseDiagnostics(sourceFile: SourceFile): boolean { - return sourceFile.parseDiagnostics.length > 0 ? true : false; + return sourceFile.parseDiagnostics.length > 0; } - function grammarErrorOnFirstToken(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + function scanToken(scanner: Scanner, pos: number) { + scanner.setTextPos(pos); + scanner.scan(); + var start = scanner.getTokenPos(); + scanner.setTextPos(start); + scanner.scan(); + return start; + } + + function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + var sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { - var start = skipTrivia(sourceFile.text, node.pos); - diagnostics.push(createFileDiagnostic(sourceFile, start, node.end - start, message, arg0, arg1, arg2)); + var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text); + var start = scanToken(scanner, node.pos); + diagnostics.push(createFileDiagnostic(sourceFile, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); } } @@ -8694,7 +8706,8 @@ module ts { } } - function grammarErrorOnNode(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + var sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = getErrorSpanForNode(node); var start = span.end > span.pos ? skipTrivia(sourceFile.text, span.pos) : span.pos; From 16693316e5b9df1a3f123fef0aa73a6f0f9a7ce8 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 10 Dec 2014 18:34:38 -0800 Subject: [PATCH 08/74] Add isEarly flag into error from grammar checking --- .../diagnosticInformationMap.generated.ts | 164 ++++++------ src/compiler/diagnosticMessages.json | 246 ++++++++++++------ 2 files changed, 246 insertions(+), 164 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 795dc31d09c..268451c9775 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -9,33 +9,33 @@ module ts { Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed.", isEarly: true }, Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." }, Unexpected_token: { code: 1012, category: DiagnosticCategory.Error, key: "Unexpected token." }, - Catch_clause_parameter_cannot_have_a_type_annotation: { code: 1013, category: DiagnosticCategory.Error, key: "Catch clause parameter cannot have a type annotation." }, - A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." }, - Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." }, - A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." }, - An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter." }, - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier." }, - An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark." }, - An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, - An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, - An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, + Catch_clause_parameter_cannot_have_a_type_annotation: { code: 1013, category: DiagnosticCategory.Error, key: "Catch clause parameter cannot have a type annotation.", isEarly: true }, + A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list.", isEarly: true }, + Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer.", isEarly: true }, + A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter.", isEarly: true }, + An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter.", isEarly: true }, + An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier.", isEarly: true }, + An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark.", isEarly: true }, + An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer.", isEarly: true }, + An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation.", isEarly: true }, + An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation.", isEarly: true }, + An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'.", isEarly: true }, A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, A_class_can_only_extend_a_single_class: { code: 1026, category: DiagnosticCategory.Error, key: "A class can only extend a single class." }, A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, - Accessibility_modifier_already_seen: { code: 1028, category: DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, - _0_modifier_must_precede_1_modifier: { code: 1029, category: DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, - _0_modifier_already_seen: { code: 1030, category: DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, - _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, + Accessibility_modifier_already_seen: { code: 1028, category: DiagnosticCategory.Error, key: "Accessibility modifier already seen.", isEarly: true }, + _0_modifier_must_precede_1_modifier: { code: 1029, category: DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier.", isEarly: true }, + _0_modifier_already_seen: { code: 1030, category: DiagnosticCategory.Error, key: "'{0}' modifier already seen.", isEarly: true }, + _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element.", isEarly: true }, An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, - Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, - Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, - A_function_implementation_cannot_be_declared_in_an_ambient_context: { code: 1037, category: DiagnosticCategory.Error, key: "A function implementation cannot be declared in an ambient context." }, + Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names.", isEarly: true }, + Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts.", isEarly: true }, + A_function_implementation_cannot_be_declared_in_an_ambient_context: { code: 1037, category: DiagnosticCategory.Error, key: "A function implementation cannot be declared in an ambient context.", isEarly: true }, A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, - Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, + Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts.", isEarly: true }, + _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element.", isEarly: true }, A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, @@ -43,50 +43,50 @@ module ts { A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, - A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, - A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, - Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer." }, - An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, + A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter.", isEarly: true }, + A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters.", isEarly: true }, + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher.", isEarly: true }, + Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer.", isEarly: true }, + An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module.", isEarly: true }, + Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers.", isEarly: true }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, - An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, - _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration." }, - _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, - Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration." }, - Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration." }, + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher.", isEarly: true }, + An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context.", isEarly: true }, + _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration.", isEarly: true }, + _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter.", isEarly: true }, + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement.", isEarly: true }, + Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration.", isEarly: true }, + Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration.", isEarly: true }, An_accessor_cannot_have_type_parameters: { code: 1094, category: DiagnosticCategory.Error, key: "An accessor cannot have type parameters." }, A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." }, - An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: DiagnosticCategory.Error, key: "An index signature must have exactly one parameter." }, - _0_list_cannot_be_empty: { code: 1097, category: DiagnosticCategory.Error, key: "'{0}' list cannot be empty." }, - Type_parameter_list_cannot_be_empty: { code: 1098, category: DiagnosticCategory.Error, key: "Type parameter list cannot be empty." }, + An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: DiagnosticCategory.Error, key: "An index signature must have exactly one parameter.", isEarly: true }, + _0_list_cannot_be_empty: { code: 1097, category: DiagnosticCategory.Error, key: "'{0}' list cannot be empty.", isEarly: true }, + Type_parameter_list_cannot_be_empty: { code: 1098, category: DiagnosticCategory.Error, key: "Type parameter list cannot be empty.", isEarly: true }, Type_argument_list_cannot_be_empty: { code: 1099, category: DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, - Invalid_use_of_0_in_strict_mode: { code: 1100, category: DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode." }, - with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." }, - delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." }, - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, - Jump_target_cannot_cross_function_boundary: { code: 1107, category: DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." }, - A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." }, - Expression_expected: { code: 1109, category: DiagnosticCategory.Error, key: "Expression expected." }, + Invalid_use_of_0_in_strict_mode: { code: 1100, category: DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode.", isEarly: true }, + with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode.", isEarly: true }, + delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode.", isEarly: true }, + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement.", isEarly: true }, + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement.", isEarly: true }, + Jump_target_cannot_cross_function_boundary: { code: 1107, category: DiagnosticCategory.Error, key: "Jump target cannot cross function boundary.", isEarly: true }, + A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body.", isEarly: true }, + Expression_expected: { code: 1109, category: DiagnosticCategory.Error, key: "Expression expected.", isEarly: true }, Type_expected: { code: 1110, category: DiagnosticCategory.Error, key: "Type expected.", isEarly: true }, - A_constructor_implementation_cannot_be_declared_in_an_ambient_context: { code: 1111, category: DiagnosticCategory.Error, key: "A constructor implementation cannot be declared in an ambient context." }, - A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, + A_constructor_implementation_cannot_be_declared_in_an_ambient_context: { code: 1111, category: DiagnosticCategory.Error, key: "A constructor implementation cannot be declared in an ambient context.", isEarly: true }, + A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional.", isEarly: true }, A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: DiagnosticCategory.Error, key: "Duplicate label '{0}'" }, - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." }, - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." }, - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." }, - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, - An_export_assignment_cannot_have_modifiers: { code: 1120, category: DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." }, - Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." }, + Duplicate_label_0: { code: 1114, category: DiagnosticCategory.Error, key: "Duplicate label '{0}'", isEarly: true }, + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement.", isEarly: true }, + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement.", isEarly: true }, + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode.", isEarly: true }, + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name.", isEarly: true }, + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name.", isEarly: true }, + An_export_assignment_cannot_have_modifiers: { code: 1120, category: DiagnosticCategory.Error, key: "An export assignment cannot have modifiers.", isEarly: true }, + Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode.", isEarly: true }, A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: DiagnosticCategory.Error, key: "A tuple type element list cannot be empty.", isEarly: true }, - Variable_declaration_list_cannot_be_empty: { code: 1123, category: DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." }, + Variable_declaration_list_cannot_be_empty: { code: 1123, category: DiagnosticCategory.Error, key: "Variable declaration list cannot be empty.", isEarly: true }, Digit_expected: { code: 1124, category: DiagnosticCategory.Error, key: "Digit expected." }, Hexadecimal_digit_expected: { code: 1125, category: DiagnosticCategory.Error, key: "Hexadecimal digit expected." }, Unexpected_end_of_text: { code: 1126, category: DiagnosticCategory.Error, key: "Unexpected end of text." }, @@ -98,52 +98,52 @@ module ts { Enum_member_expected: { code: 1132, category: DiagnosticCategory.Error, key: "Enum member expected." }, Type_reference_expected: { code: 1133, category: DiagnosticCategory.Error, key: "Type reference expected." }, Variable_declaration_expected: { code: 1134, category: DiagnosticCategory.Error, key: "Variable declaration expected." }, - Argument_expression_expected: { code: 1135, category: DiagnosticCategory.Error, key: "Argument expression expected." }, + Argument_expression_expected: { code: 1135, category: DiagnosticCategory.Error, key: "Argument expression expected.", isEarly: true }, Property_assignment_expected: { code: 1136, category: DiagnosticCategory.Error, key: "Property assignment expected." }, Expression_or_comma_expected: { code: 1137, category: DiagnosticCategory.Error, key: "Expression or comma expected." }, Parameter_declaration_expected: { code: 1138, category: DiagnosticCategory.Error, key: "Parameter declaration expected." }, Type_parameter_declaration_expected: { code: 1139, category: DiagnosticCategory.Error, key: "Type parameter declaration expected." }, Type_argument_expected: { code: 1140, category: DiagnosticCategory.Error, key: "Type argument expected." }, - String_literal_expected: { code: 1141, category: DiagnosticCategory.Error, key: "String literal expected." }, + String_literal_expected: { code: 1141, category: DiagnosticCategory.Error, key: "String literal expected.", isEarly: true }, Line_break_not_permitted_here: { code: 1142, category: DiagnosticCategory.Error, key: "Line break not permitted here." }, or_expected: { code: 1144, category: DiagnosticCategory.Error, key: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, + Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members.", isEarly: true }, Declaration_expected: { code: 1146, category: DiagnosticCategory.Error, key: "Declaration expected." }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." }, + Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module.", isEarly: true }, Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." }, Filename_0_differs_from_already_included_filename_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "Filename '{0}' differs from already included filename '{1}' only in casing" }, - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", isEarly: true }, var_let_or_const_expected: { code: 1152, category: DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, - const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, - let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, + let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher.", isEarly: true }, + const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher.", isEarly: true }, + const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized", isEarly: true }, + const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block.", isEarly: true }, + let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block.", isEarly: true }, Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, - yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, - Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in an ambient context." }, - Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in class property declarations." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, - Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in method overloads." }, - Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces." }, - Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in type literals." }, + yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration.", isEarly: true }, + Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums.", isEarly: true }, + Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in an ambient context.", isEarly: true }, + Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in class property declarations.", isEarly: true }, + Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher.", isEarly: true }, + Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in method overloads.", isEarly: true }, + Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces.", isEarly: true }, + Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in type literals.", isEarly: true }, A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, - extends_clause_already_seen: { code: 1172, category: DiagnosticCategory.Error, key: "'extends' clause already seen." }, - extends_clause_must_precede_implements_clause: { code: 1173, category: DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." }, - Classes_can_only_extend_a_single_class: { code: 1174, category: DiagnosticCategory.Error, key: "Classes can only extend a single class." }, - implements_clause_already_seen: { code: 1175, category: DiagnosticCategory.Error, key: "'implements' clause already seen." }, - Interface_declaration_cannot_have_implements_clause: { code: 1176, category: DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." }, + extends_clause_already_seen: { code: 1172, category: DiagnosticCategory.Error, key: "'extends' clause already seen.", isEarly: true }, + extends_clause_must_precede_implements_clause: { code: 1173, category: DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause.", isEarly: true }, + Classes_can_only_extend_a_single_class: { code: 1174, category: DiagnosticCategory.Error, key: "Classes can only extend a single class.", isEarly: true }, + implements_clause_already_seen: { code: 1175, category: DiagnosticCategory.Error, key: "'implements' clause already seen.", isEarly: true }, + Interface_declaration_cannot_have_implements_clause: { code: 1176, category: DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause.", isEarly: true }, Binary_digit_expected: { code: 1177, category: DiagnosticCategory.Error, key: "Binary digit expected." }, Octal_digit_expected: { code: 1178, category: DiagnosticCategory.Error, key: "Octal digit expected." }, Unexpected_token_expected: { code: 1179, category: DiagnosticCategory.Error, key: "Unexpected token. '{' expected." }, Property_destructuring_pattern_expected: { code: 1180, category: DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, Array_element_destructuring_pattern_expected: { code: 1181, category: DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, - A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, + A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer.", isEarly: true }, + Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts.", isEarly: true }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -433,7 +433,7 @@ module ts { _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, - yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." }, - generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "'generators' are not currently supported." }, + yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported.", isEarly: true }, + generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "'generators' are not currently supported.", isEarly: true }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f3fc9b9b715..03fad9f5ace 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -30,47 +30,58 @@ }, "Catch clause parameter cannot have a type annotation.": { "category": "Error", - "code": 1013 + "code": 1013, + "isEarly": true }, "A rest parameter must be last in a parameter list.": { "category": "Error", - "code": 1014 + "code": 1014, + "isEarly": true }, "Parameter cannot have question mark and initializer.": { "category": "Error", - "code": 1015 + "code": 1015, + "isEarly": true }, "A required parameter cannot follow an optional parameter.": { "category": "Error", - "code": 1016 + "code": 1016, + "isEarly": true }, "An index signature cannot have a rest parameter.": { "category": "Error", - "code": 1017 + "code": 1017, + "isEarly": true }, "An index signature parameter cannot have an accessibility modifier.": { "category": "Error", - "code": 1018 + "code": 1018, + "isEarly": true }, "An index signature parameter cannot have a question mark.": { "category": "Error", - "code": 1019 + "code": 1019, + "isEarly": true }, "An index signature parameter cannot have an initializer.": { "category": "Error", - "code": 1020 + "code": 1020, + "isEarly": true }, "An index signature must have a type annotation.": { "category": "Error", - "code": 1021 + "code": 1021, + "isEarly": true }, "An index signature parameter must have a type annotation.": { "category": "Error", - "code": 1022 + "code": 1022, + "isEarly": true }, "An index signature parameter type must be 'string' or 'number'.": { "category": "Error", - "code": 1023 + "code": 1023, + "isEarly": true }, "A class or interface declaration can only have one 'extends' clause.": { "category": "Error", @@ -90,19 +101,23 @@ }, "Accessibility modifier already seen.": { "category": "Error", - "code": 1028 + "code": 1028, + "isEarly": true }, "'{0}' modifier must precede '{1}' modifier.": { "category": "Error", - "code": 1029 + "code": 1029, + "isEarly": true }, "'{0}' modifier already seen.": { "category": "Error", - "code": 1030 + "code": 1030, + "isEarly": true }, "'{0}' modifier cannot appear on a class element.": { "category": "Error", - "code": 1031 + "code": 1031, + "isEarly": true }, "An interface declaration cannot have an 'implements' clause.": { "category": "Error", @@ -114,15 +129,18 @@ }, "Only ambient modules can use quoted names.": { "category": "Error", - "code": 1035 + "code": 1035, + "isEarly": true }, "Statements are not allowed in ambient contexts.": { "category": "Error", - "code": 1036 + "code": 1036, + "isEarly": true }, "A function implementation cannot be declared in an ambient context.": { "category": "Error", - "code": 1037 + "code": 1037, + "isEarly": true }, "A 'declare' modifier cannot be used in an already ambient context.": { "category": "Error", @@ -130,11 +148,13 @@ }, "Initializers are not allowed in ambient contexts.": { "category": "Error", - "code": 1039 + "code": 1039, + "isEarly": true }, "'{0}' modifier cannot appear on a module element.": { "category": "Error", - "code": 1044 + "code": 1044, + "isEarly": true }, "A 'declare' modifier cannot be used with an interface declaration.": { "category": "Error", @@ -166,27 +186,33 @@ }, "A 'set' accessor cannot have rest parameter.": { "category": "Error", - "code": 1053 + "code": 1053, + "isEarly": true }, "A 'get' accessor cannot have parameters.": { "category": "Error", - "code": 1054 + "code": 1054, + "isEarly": true }, "Accessors are only available when targeting ECMAScript 5 and higher.": { "category": "Error", - "code": 1056 + "code": 1056, + "isEarly": true }, "Enum member must have initializer.": { "category": "Error", - "code": 1061 + "code": 1061, + "isEarly": true }, "An export assignment cannot be used in an internal module.": { "category": "Error", - "code": 1063 + "code": 1063, + "isEarly": true }, "Ambient enum elements can only have integer literal initializers.": { "category": "Error", - "code": 1066 + "code": 1066, + "isEarly": true }, "Unexpected token. A constructor, method, accessor, or property was expected.": { "category": "Error", @@ -202,31 +228,38 @@ }, "Octal literals are not available when targeting ECMAScript 5 and higher.": { "category": "Error", - "code": 1085 + "code": 1085, + "isEarly": true }, "An accessor cannot be declared in an ambient context.": { "category": "Error", - "code": 1086 + "code": 1086, + "isEarly": true }, "'{0}' modifier cannot appear on a constructor declaration.": { "category": "Error", - "code": 1089 + "code": 1089, + "isEarly": true }, "'{0}' modifier cannot appear on a parameter.": { "category": "Error", - "code": 1090 + "code": 1090, + "isEarly": true }, "Only a single variable declaration is allowed in a 'for...in' statement.": { "category": "Error", - "code": 1091 + "code": 1091, + "isEarly": true }, "Type parameters cannot appear on a constructor declaration.": { "category": "Error", - "code": 1092 + "code": 1092, + "isEarly": true }, "Type annotation cannot appear on a constructor declaration.": { "category": "Error", - "code": 1093 + "code": 1093, + "isEarly": true }, "An accessor cannot have type parameters.": { "category": "Error", @@ -238,15 +271,18 @@ }, "An index signature must have exactly one parameter.": { "category": "Error", - "code": 1096 + "code": 1096, + "isEarly": true }, "'{0}' list cannot be empty.": { "category": "Error", - "code": 1097 + "code": 1097, + "isEarly": true }, "Type parameter list cannot be empty.": { "category": "Error", - "code": 1098 + "code": 1098, + "isEarly": true }, "Type argument list cannot be empty.": { "category": "Error", @@ -254,35 +290,43 @@ }, "Invalid use of '{0}' in strict mode.": { "category": "Error", - "code": 1100 + "code": 1100, + "isEarly": true }, "'with' statements are not allowed in strict mode.": { "category": "Error", - "code": 1101 + "code": 1101, + "isEarly": true }, "'delete' cannot be called on an identifier in strict mode.": { "category": "Error", - "code": 1102 + "code": 1102, + "isEarly": true }, "A 'continue' statement can only be used within an enclosing iteration statement.": { "category": "Error", - "code": 1104 + "code": 1104, + "isEarly": true }, "A 'break' statement can only be used within an enclosing iteration or switch statement.": { "category": "Error", - "code": 1105 + "code": 1105, + "isEarly": true }, "Jump target cannot cross function boundary.": { "category": "Error", - "code": 1107 + "code": 1107, + "isEarly": true }, "A 'return' statement can only be used within a function body.": { "category": "Error", - "code": 1108 + "code": 1108, + "isEarly": true }, "Expression expected.": { "category": "Error", - "code": 1109 + "code": 1109, + "isEarly": true }, "Type expected.": { "category": "Error", @@ -291,11 +335,13 @@ }, "A constructor implementation cannot be declared in an ambient context.": { "category": "Error", - "code": 1111 + "code": 1111, + "isEarly": true }, "A class member cannot be declared optional.": { "category": "Error", - "code": 1112 + "code": 1112, + "isEarly": true }, "A 'default' clause cannot appear more than once in a 'switch' statement.": { "category": "Error", @@ -303,35 +349,43 @@ }, "Duplicate label '{0}'": { "category": "Error", - "code": 1114 + "code": 1114, + "isEarly": true }, "A 'continue' statement can only jump to a label of an enclosing iteration statement.": { "category": "Error", - "code": 1115 + "code": 1115, + "isEarly": true }, "A 'break' statement can only jump to a label of an enclosing statement.": { "category": "Error", - "code": 1116 + "code": 1116, + "isEarly": true }, "An object literal cannot have multiple properties with the same name in strict mode.": { "category": "Error", - "code": 1117 + "code": 1117, + "isEarly": true }, "An object literal cannot have multiple get/set accessors with the same name.": { "category": "Error", - "code": 1118 + "code": 1118, + "isEarly": true }, "An object literal cannot have property and accessor with the same name.": { "category": "Error", - "code": 1119 + "code": 1119, + "isEarly": true }, "An export assignment cannot have modifiers.": { "category": "Error", - "code": 1120 + "code": 1120, + "isEarly": true }, "Octal literals are not allowed in strict mode.": { "category": "Error", - "code": 1121 + "code": 1121, + "isEarly": true }, "A tuple type element list cannot be empty.": { "category": "Error", @@ -340,7 +394,8 @@ }, "Variable declaration list cannot be empty.": { "category": "Error", - "code": 1123 + "code": 1123, + "isEarly": true }, "Digit expected.": { "category": "Error", @@ -388,7 +443,8 @@ }, "Argument expression expected.": { "category": "Error", - "code": 1135 + "code": 1135, + "isEarly": true }, "Property assignment expected.": { "category": "Error", @@ -412,7 +468,8 @@ }, "String literal expected.": { "category": "Error", - "code": 1141 + "code": 1141, + "isEarly": true }, "Line break not permitted here.": { "category": "Error", @@ -424,7 +481,8 @@ }, "Modifiers not permitted on index signature members.": { "category": "Error", - "code": 1145 + "code": 1145, + "isEarly": true }, "Declaration expected.": { "category": "Error", @@ -432,7 +490,8 @@ }, "Import declarations in an internal module cannot reference an external module.": { "category": "Error", - "code": 1147 + "code": 1147, + "isEarly": true }, "Cannot compile external modules unless the '--module' flag is provided.": { "category": "Error", @@ -444,7 +503,8 @@ }, "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { "category": "Error", - "code": 1150 + "code": 1150, + "isEarly": true }, "'var', 'let' or 'const' expected.": { "category": "Error", @@ -452,23 +512,28 @@ }, "'let' declarations are only available when targeting ECMAScript 6 and higher.": { "category": "Error", - "code": 1153 + "code": 1153, + "isEarly": true }, "'const' declarations are only available when targeting ECMAScript 6 and higher.": { "category": "Error", - "code": 1154 + "code": 1154, + "isEarly": true }, "'const' declarations must be initialized": { "category": "Error", - "code": 1155 + "code": 1155, + "isEarly": true }, "'const' declarations can only be declared inside a block.": { "category": "Error", - "code": 1156 + "code": 1156, + "isEarly": true }, "'let' declarations can only be declared inside a block.": { "category": "Error", - "code": 1157 + "code": 1157, + "isEarly": true }, "Tagged templates are only available when targeting ECMAScript 6 and higher.": { "category": "Error", @@ -489,35 +554,43 @@ "'yield' expression must be contained_within a generator declaration." : { "category": "Error", - "code": 1163 + "code": 1163, + "isEarly": true }, "Computed property names are not allowed in enums.": { "category": "Error", - "code": 1164 + "code": 1164, + "isEarly": true }, "Computed property names are not allowed in an ambient context.": { "category": "Error", - "code": 1165 + "code": 1165, + "isEarly": true }, "Computed property names are not allowed in class property declarations.": { "category": "Error", - "code": 1166 + "code": 1166, + "isEarly": true }, "Computed property names are only available when targeting ECMAScript 6 and higher.": { "category": "Error", - "code": 1167 + "code": 1167, + "isEarly": true }, "Computed property names are not allowed in method overloads.": { "category": "Error", - "code": 1168 + "code": 1168, + "isEarly": true }, "Computed property names are not allowed in interfaces.": { "category": "Error", - "code": 1169 + "code": 1169, + "isEarly": true }, "Computed property names are not allowed in type literals.": { "category": "Error", - "code": 1170 + "code": 1170, + "isEarly": true }, "A comma expression is not allowed in a computed property name.": { "category": "Error", @@ -525,23 +598,28 @@ }, "'extends' clause already seen.": { "category": "Error", - "code": 1172 + "code": 1172, + "isEarly": true }, "'extends' clause must precede 'implements' clause.": { "category": "Error", - "code": 1173 + "code": 1173, + "isEarly": true }, "Classes can only extend a single class.": { "category": "Error", - "code": 1174 + "code": 1174, + "isEarly": true }, "'implements' clause already seen.": { "category": "Error", - "code": 1175 + "code": 1175, + "isEarly": true }, "Interface declaration cannot have 'implements' clause.": { "category": "Error", - "code": 1176 + "code": 1176, + "isEarly": true }, "Binary digit expected.": { "category": "Error", @@ -565,11 +643,13 @@ }, "A destructuring declaration must have an initializer.": { "category": "Error", - "code": 1182 + "code": 1182, + "isEarly": true }, "Destructuring declarations are not allowed in ambient contexts.": { "category": "Error", - "code": 1183 + "code": 1183, + "isEarly": true }, "Duplicate identifier '{0}'.": { @@ -1737,10 +1817,12 @@ }, "'yield' expressions are not currently supported.": { "category": "Error", - "code": 9000 + "code": 9000, + "isEarly": true }, "'generators' are not currently supported.": { "category": "Error", - "code": 9001 + "code": 9001, + "isEarly": true } } From 31e49ed93eb447317f16485bba13af7c084b0980 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 10 Dec 2014 18:39:24 -0800 Subject: [PATCH 09/74] Move grammar checking: callSignature, constructorType, ConstructSignature, FunctionType, IndexSignature --- src/compiler/checker.ts | 325 +++++++++++++++--- src/compiler/parser.ts | 8 +- ...OptionalParameterAndInitializer.errors.txt | 4 +- ...eReferenceWithoutTypeArgument.d.errors.txt | 2 +- ...ypeReferenceWithoutTypeArgument.errors.txt | 2 +- ...peReferenceWithoutTypeArgument2.errors.txt | 2 +- ...peReferenceWithoutTypeArgument3.errors.txt | 2 +- tests/baselines/reference/giant.errors.txt | 32 +- ...SignatureMustHaveTypeAnnotation.errors.txt | 2 +- ...natureWithAccessibilityModifier.errors.txt | 12 +- .../reference/indexTypeCheck.errors.txt | 4 +- .../parserIndexSignature2.errors.txt | 6 +- .../reference/parserObjectType6.errors.txt | 2 +- .../typeParameterConstraints1.errors.txt | 2 +- 14 files changed, 314 insertions(+), 91 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f8280ffd230..aff559c9261 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8667,54 +8667,6 @@ module ts { return node; } - // GRAMMAR CHECKING - function checkGrammarForDisallowedTrailingComma(list: NodeArray): boolean { - if (list && list.hasTrailingComma) { - var start = list.end - ",".length; - var end = list.end; - var sourceFile = getSourceFileOfNode(list[0]); - grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Trailing_comma_not_allowed); - return true; - } - } - - function hasParseDiagnostics(sourceFile: SourceFile): boolean { - return sourceFile.parseDiagnostics.length > 0; - } - - function scanToken(scanner: Scanner, pos: number) { - scanner.setTextPos(pos); - scanner.scan(); - var start = scanner.getTokenPos(); - scanner.setTextPos(start); - scanner.scan(); - return start; - } - - function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { - var sourceFile = getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text); - var start = scanToken(scanner, node.pos); - diagnostics.push(createFileDiagnostic(sourceFile, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); - } - } - - function grammarErrorAtPos(sourceFile: SourceFile, start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { - if (!hasParseDiagnostics(sourceFile)) { - diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); - } - } - - function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { - var sourceFile = getSourceFileOfNode(node); - if (!hasParseDiagnostics(sourceFile)) { - var span = getErrorSpanForNode(node); - var start = span.end > span.pos ? skipTrivia(sourceFile.text, span.pos) : span.pos; - diagnostics.push(createFileDiagnostic(sourceFile, start, span.end - start, message, arg0, arg1, arg2)); - } - } - function checkImportDeclaration(node: ImportDeclaration) { checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -8803,7 +8755,12 @@ module ts { case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: + // Grammar checking + checkGrammarSignatureDeclaration(node) + return checkSignatureDeclaration(node); case SyntaxKind.IndexSignature: + // Grammar checking + checkGrammarIndexSignature(node); return checkSignatureDeclaration(node); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: @@ -9682,6 +9639,278 @@ module ts { anyArrayType = createArrayType(anyType); } + + // GRAMMAR CHECKING + function checkModifiers(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.Constructor: + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.IndexSignature: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.ExportAssignment: + case SyntaxKind.VariableStatement: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.ImportDeclaration: + case SyntaxKind.Parameter: + break; + default: + return false; + } + + if (!node.modifiers) { + return; + } + + var lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node; + var flags = 0; + for (var i = 0, n = node.modifiers.length; i < n; i++) { + var modifier = node.modifiers[i]; + + switch (modifier.kind) { + case SyntaxKind.PublicKeyword: + case SyntaxKind.ProtectedKeyword: + case SyntaxKind.PrivateKeyword: + var text: string; + if (modifier.kind === SyntaxKind.PublicKeyword) { + text = "public"; + } + else if (modifier.kind === SyntaxKind.ProtectedKeyword) { + text = "protected"; + lastProtected = modifier; + } + else { + text = "private"; + lastPrivate = modifier; + } + + if (flags & NodeFlags.AccessibilityModifier) { + return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen); + } + else if (flags & NodeFlags.Static) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); + } + else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); + } + flags |= modifierToFlag(modifier.kind); + break; + + case SyntaxKind.StaticKeyword: + if (flags & NodeFlags.Static) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "static"); + } + else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); + } + else if (node.kind === SyntaxKind.Parameter) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); + } + flags |= NodeFlags.Static; + lastStatic = modifier; + break; + + case SyntaxKind.ExportKeyword: + if (flags & NodeFlags.Export) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "export"); + } + else if (flags & NodeFlags.Ambient) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); + } + else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); + } + else if (node.kind === SyntaxKind.Parameter) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); + } + flags |= NodeFlags.Export; + break; + + case SyntaxKind.DeclareKeyword: + // TODO (yuisu) : Bring back the parser grammar checking + break; + } + } + + if (node.kind === SyntaxKind.Constructor) { + if (flags & NodeFlags.Static) { + return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); + } + else if (flags & NodeFlags.Protected) { + return grammarErrorOnNode(lastProtected, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); + } + else if (flags & NodeFlags.Private) { + return grammarErrorOnNode(lastPrivate, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); + } + } + else if (node.kind === SyntaxKind.ImportDeclaration && flags & NodeFlags.Ambient) { + return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); + } + else if (node.kind === SyntaxKind.InterfaceDeclaration && flags & NodeFlags.Ambient) { + return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); + } + } + + function checkGrammarForDisallowedTrailingComma(list: NodeArray): boolean { + if (list && list.hasTrailingComma) { + var start = list.end - ",".length; + var end = list.end; + var sourceFile = getSourceFileOfNode(list[0]); + return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Trailing_comma_not_allowed); + } + } + + function checkGrammarTypeParameterList(signatureDecl: SignatureDeclaration, typeParameters: NodeArray): boolean { + if (checkGrammarForDisallowedTrailingComma(typeParameters)) { + return true; + } + + if (typeParameters && typeParameters.length === 0) { + var start = typeParameters.pos - "<".length; + var sourceFile = getSourceFileOfNode(signatureDecl); + var end = skipTrivia(sourceFile.text, typeParameters.end) + ">".length; + return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty); + } + } + + function checkGrammarParameterList(parameters: NodeArray) { + if (checkGrammarForDisallowedTrailingComma(parameters)) { + return true; + } + + var seenOptionalParameter = false; + var parameterCount = parameters.length; + + for (var i = 0; i < parameterCount; i++) { + var parameter = parameters[i]; + if (parameter.dotDotDotToken) { + if (i !== (parameterCount - 1)) { + return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + } + + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, Diagnostics.A_rest_parameter_cannot_be_optional); + } + + if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_have_an_initializer); + } + } + else if (parameter.questionToken || parameter.initializer) { + seenOptionalParameter = true; + + if (parameter.questionToken && parameter.initializer) { + return grammarErrorOnNode(parameter.name, Diagnostics.Parameter_cannot_have_question_mark_and_initializer); + } + } + else { + if (seenOptionalParameter) { + return grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); + } + } + } + } + + function checkGrammarSignatureDeclaration(node: SignatureDeclaration) { + if (!checkGrammarTypeParameterList(node, node.typeParameters)) { + checkGrammarParameterList(node.parameters); + } + } + + function checkGrammarIndexSignatureParameters(node: SignatureDeclaration): boolean { + var parameter = node.parameters[0]; + if (node.parameters.length !== 1) { + if (parameter) { + return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_must_have_exactly_one_parameter); + } + else { + return grammarErrorOnNode(node, Diagnostics.An_index_signature_must_have_exactly_one_parameter); + } + } + else if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.An_index_signature_cannot_have_a_rest_parameter); + } + else if (parameter.flags & NodeFlags.Modifier) { + return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); + } + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); + } + else if (parameter.initializer) { + return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); + } + else if (!parameter.type) { + return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); + } + else if (parameter.type.kind !== SyntaxKind.StringKeyword && parameter.type.kind !== SyntaxKind.NumberKeyword) { + return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + } + else if (!node.type) { + return grammarErrorOnNode(node, Diagnostics.An_index_signature_must_have_a_type_annotation); + } + } + + function checkGrammarForIndexSignatureModifier(node: SignatureDeclaration): void { + if (node.flags & NodeFlags.Modifier) { + grammarErrorOnFirstToken(node, Diagnostics.Modifiers_not_permitted_on_index_signature_members); + } + } + + function checkGrammarIndexSignature(node: SignatureDeclaration) { + var hasErrorFromCheckModifiersOrParameters = checkModifiers(node) ? true: checkGrammarIndexSignatureParameters(node); + if (!hasErrorFromCheckModifiersOrParameters) { + checkGrammarForIndexSignatureModifier(node); + } + } + + function hasParseDiagnostics(sourceFile: SourceFile): boolean { + return sourceFile.parseDiagnostics.length > 0; + } + + function scanToken(scanner: Scanner, pos: number) { + scanner.setTextPos(pos); + scanner.scan(); + var start = scanner.getTokenPos(); + scanner.setTextPos(start); + scanner.scan(); + return start; + } + + function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { + var sourceFile = getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text); + var start = scanToken(scanner, node.pos); + diagnostics.push(createFileDiagnostic(sourceFile, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); + return true; + } + } + + function grammarErrorAtPos(sourceFile: SourceFile, start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { + if (!hasParseDiagnostics(sourceFile)) { + diagnostics.push(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); + return true; + } + } + + function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { + var sourceFile = getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var span = getErrorSpanForNode(node); + var start = span.end > span.pos ? skipTrivia(sourceFile.text, span.pos) : span.pos; + diagnostics.push(createFileDiagnostic(sourceFile, start, span.end - start, message, arg0, arg1, arg2)); + return true; + } + } + initializeTypeChecker(); return checker; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5b2b8ad0dad..b0a544cb80c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1002,7 +1002,7 @@ module ts { return false; } - function modifierToFlag(token: SyntaxKind): NodeFlags { + export function modifierToFlag(token: SyntaxKind): NodeFlags { switch (token) { case SyntaxKind.StaticKeyword: return NodeFlags.Static; case SyntaxKind.PublicKeyword: return NodeFlags.Public; @@ -4626,10 +4626,6 @@ module ts { // Now do node specific checks. switch (nodeKind) { case SyntaxKind.ArrowFunction: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructorType: - case SyntaxKind.ConstructSignature: - case SyntaxKind.FunctionType: return checkAnySignatureDeclaration(node); case SyntaxKind.BreakStatement: case SyntaxKind.ContinueStatement: @@ -4655,7 +4651,6 @@ module ts { case SyntaxKind.FunctionExpression: return checkFunctionExpression(node); case SyntaxKind.GetAccessor: return checkGetAccessor(node); case SyntaxKind.HeritageClause: return checkHeritageClause(node); - case SyntaxKind.IndexSignature: return checkIndexSignature(node); case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node); case SyntaxKind.LabeledStatement: return checkLabeledStatement(node); case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(node); @@ -5335,7 +5330,6 @@ module ts { case SyntaxKind.PropertySignature: case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: - case SyntaxKind.IndexSignature: case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.ModuleDeclaration: diff --git a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt index 35718ca9612..ecb1c877296 100644 --- a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt +++ b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt @@ -2,15 +2,15 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWith tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(4,22): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(5,22): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(15,9): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(34,6): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(44,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(46,9): error TS1015: Parameter cannot have question mark and initializer. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(34,6): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(34,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS2322: Type 'string' is not assignable to type 'number'. diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt index f646ac4725e..6c98d419dec 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.d.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,19): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(8,16): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(10,21): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(11,22): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(11,26): error TS2314: Generic type 'C' requires 1 type argument(s). +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,19): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,22): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(12,26): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.d.ts(14,23): error TS2314: Generic type 'C' requires 1 type argument(s). diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.errors.txt index a8627f3f18e..d57f3c2fc0d 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,11): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(8,8): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(10,13): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(11,14): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(11,18): error TS2314: Generic type 'C' requires 1 type argument(s). +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,11): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,14): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(12,18): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument.ts(14,13): error TS2314: Generic type 'C' requires 1 type argument(s). diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt index 1802d0385c4..745da9aa106 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,11): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(8,8): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(10,13): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(11,14): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(11,18): error TS2314: Generic type 'I' requires 1 type argument(s). +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,11): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,14): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(12,18): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(14,13): error TS2314: Generic type 'I' requires 1 type argument(s). diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt index 41774da0d00..1fec52356a2 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,19): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(8,16): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(10,21): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(11,22): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(11,26): error TS2314: Generic type 'C' requires 1 type argument(s). +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,19): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,22): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(12,26): error TS2314: Generic type 'C' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument3.ts(14,23): error TS2314: Generic type 'C' requires 1 type argument(s). diff --git a/tests/baselines/reference/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index f971c067768..782f10212bd 100644 --- a/tests/baselines/reference/giant.errors.txt +++ b/tests/baselines/reference/giant.errors.txt @@ -5,8 +5,6 @@ tests/cases/compiler/giant.ts(30,17): error TS1056: Accessors are only available tests/cases/compiler/giant.ts(34,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(61,5): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/compiler/giant.ts(62,5): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(63,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(88,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(90,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(92,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -14,8 +12,6 @@ tests/cases/compiler/giant.ts(94,21): error TS1056: Accessors are only available tests/cases/compiler/giant.ts(98,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(100,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(125,9): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/compiler/giant.ts(126,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(127,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(154,39): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(167,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(169,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -24,8 +20,6 @@ tests/cases/compiler/giant.ts(173,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(177,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(179,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(204,9): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/compiler/giant.ts(205,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(206,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(233,39): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(238,35): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(240,24): error TS1111: A constructor implementation cannot be declared in an ambient context. @@ -55,8 +49,6 @@ tests/cases/compiler/giant.ts(288,17): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(292,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(294,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(319,5): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/compiler/giant.ts(320,5): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(321,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(346,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(348,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(350,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -64,8 +56,6 @@ tests/cases/compiler/giant.ts(352,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(356,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(358,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(383,9): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/compiler/giant.ts(384,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(385,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(412,39): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(425,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(427,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -74,8 +64,6 @@ tests/cases/compiler/giant.ts(431,21): error TS1056: Accessors are only availabl tests/cases/compiler/giant.ts(435,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(437,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(462,9): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/compiler/giant.ts(463,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(464,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(491,39): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(496,35): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(498,24): error TS1111: A constructor implementation cannot be declared in an ambient context. @@ -121,8 +109,6 @@ tests/cases/compiler/giant.ts(558,24): error TS1111: A constructor implementatio tests/cases/compiler/giant.ts(561,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(563,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(587,9): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(606,22): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(606,25): error TS1036: Statements are not allowed in ambient contexts. tests/cases/compiler/giant.ts(611,30): error TS1037: A function implementation cannot be declared in an ambient context. @@ -138,8 +124,6 @@ tests/cases/compiler/giant.ts(623,24): error TS1111: A constructor implementatio tests/cases/compiler/giant.ts(626,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(628,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(653,9): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(672,22): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(672,25): error TS1036: Statements are not allowed in ambient contexts. tests/cases/compiler/giant.ts(676,30): error TS1037: A function implementation cannot be declared in an ambient context. @@ -156,6 +140,8 @@ tests/cases/compiler/giant.ts(33,12): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(34,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(35,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(36,16): error TS2300: Duplicate identifier 'tgF'. +tests/cases/compiler/giant.ts(62,5): error TS1021: An index signature must have a type annotation. +tests/cases/compiler/giant.ts(63,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(76,5): error TS2386: Overload signatures must all be optional or required. tests/cases/compiler/giant.ts(87,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(88,20): error TS2300: Duplicate identifier 'pgF'. @@ -169,6 +155,8 @@ tests/cases/compiler/giant.ts(97,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(98,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(99,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(100,20): error TS2300: Duplicate identifier 'tgF'. +tests/cases/compiler/giant.ts(126,9): error TS1021: An index signature must have a type annotation. +tests/cases/compiler/giant.ts(127,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(140,9): error TS2386: Overload signatures must all be optional or required. tests/cases/compiler/giant.ts(166,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(167,20): error TS2300: Duplicate identifier 'pgF'. @@ -182,6 +170,8 @@ tests/cases/compiler/giant.ts(176,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(177,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(178,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(179,20): error TS2300: Duplicate identifier 'tgF'. +tests/cases/compiler/giant.ts(205,9): error TS1021: An index signature must have a type annotation. +tests/cases/compiler/giant.ts(206,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(219,9): error TS2386: Overload signatures must all be optional or required. tests/cases/compiler/giant.ts(245,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(246,20): error TS2300: Duplicate identifier 'pgF'. @@ -207,6 +197,8 @@ tests/cases/compiler/giant.ts(291,12): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(292,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(293,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(294,16): error TS2300: Duplicate identifier 'tgF'. +tests/cases/compiler/giant.ts(320,5): error TS1021: An index signature must have a type annotation. +tests/cases/compiler/giant.ts(321,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(334,5): error TS2386: Overload signatures must all be optional or required. tests/cases/compiler/giant.ts(345,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(346,20): error TS2300: Duplicate identifier 'pgF'. @@ -220,6 +212,8 @@ tests/cases/compiler/giant.ts(355,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(356,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(357,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(358,20): error TS2300: Duplicate identifier 'tgF'. +tests/cases/compiler/giant.ts(384,9): error TS1021: An index signature must have a type annotation. +tests/cases/compiler/giant.ts(385,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(398,9): error TS2386: Overload signatures must all be optional or required. tests/cases/compiler/giant.ts(424,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(425,20): error TS2300: Duplicate identifier 'pgF'. @@ -233,6 +227,8 @@ tests/cases/compiler/giant.ts(434,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(435,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(436,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(437,20): error TS2300: Duplicate identifier 'tgF'. +tests/cases/compiler/giant.ts(463,9): error TS1021: An index signature must have a type annotation. +tests/cases/compiler/giant.ts(464,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(477,9): error TS2386: Overload signatures must all be optional or required. tests/cases/compiler/giant.ts(503,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(504,20): error TS2300: Duplicate identifier 'pgF'. @@ -258,7 +254,11 @@ tests/cases/compiler/giant.ts(549,12): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(550,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(551,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(552,16): error TS2300: Duplicate identifier 'tgF'. +tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation. +tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(602,9): error TS2386: Overload signatures must all be optional or required. +tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation. +tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all be optional or required. diff --git a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt index 294282d1e9e..7d348b2cdbc 100644 --- a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt +++ b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(2,5): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(7,5): error TS1166: Computed property names are not allowed in class property declarations. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021: An index signature must have a type annotation. diff --git a/tests/baselines/reference/indexSignatureWithAccessibilityModifier.errors.txt b/tests/baselines/reference/indexSignatureWithAccessibilityModifier.errors.txt index 6c836e268d6..84577dd5cae 100644 --- a/tests/baselines/reference/indexSignatureWithAccessibilityModifier.errors.txt +++ b/tests/baselines/reference/indexSignatureWithAccessibilityModifier.errors.txt @@ -1,22 +1,22 @@ -tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(2,13): error TS1018: An index signature parameter cannot have an accessibility modifier. -tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(6,13): error TS1018: An index signature parameter cannot have an accessibility modifier. tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(2,6): error TS2369: A parameter property is only allowed in a constructor implementation. +tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(2,13): error TS1018: An index signature parameter cannot have an accessibility modifier. tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(6,6): error TS2369: A parameter property is only allowed in a constructor implementation. +tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts(6,13): error TS1018: An index signature parameter cannot have an accessibility modifier. ==== tests/cases/compiler/indexSignatureWithAccessibilityModifier.ts (4 errors) ==== interface I { [public x: string]: string; - ~ -!!! error TS1018: An index signature parameter cannot have an accessibility modifier. ~~~~~~~~~~~~~~~~ !!! error TS2369: A parameter property is only allowed in a constructor implementation. + ~ +!!! error TS1018: An index signature parameter cannot have an accessibility modifier. } class C { [public x: string]: string - ~ -!!! error TS1018: An index signature parameter cannot have an accessibility modifier. ~~~~~~~~~~~~~~~~ !!! error TS2369: A parameter property is only allowed in a constructor implementation. + ~ +!!! error TS1018: An index signature parameter cannot have an accessibility modifier. } \ No newline at end of file diff --git a/tests/baselines/reference/indexTypeCheck.errors.txt b/tests/baselines/reference/indexTypeCheck.errors.txt index efa02c3ff1f..03d0e2ce8ed 100644 --- a/tests/baselines/reference/indexTypeCheck.errors.txt +++ b/tests/baselines/reference/indexTypeCheck.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/indexTypeCheck.ts(2,2): error TS1021: An index signature must have a type annotation. tests/cases/compiler/indexTypeCheck.ts(3,2): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'. tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. +tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter. +tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', or 'any'. diff --git a/tests/baselines/reference/parserIndexSignature2.errors.txt b/tests/baselines/reference/parserIndexSignature2.errors.txt index 8e221bdce2c..398cebebea8 100644 --- a/tests/baselines/reference/parserIndexSignature2.errors.txt +++ b/tests/baselines/reference/parserIndexSignature2.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature2.ts(2,11): error TS1018: An index signature parameter cannot have an accessibility modifier. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature2.ts(2,4): error TS2369: A parameter property is only allowed in a constructor implementation. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature2.ts(2,11): error TS1018: An index signature parameter cannot have an accessibility modifier. ==== tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature2.ts (2 errors) ==== interface I { [public a] - ~ -!!! error TS1018: An index signature parameter cannot have an accessibility modifier. ~~~~~~~~ !!! error TS2369: A parameter property is only allowed in a constructor implementation. + ~ +!!! error TS1018: An index signature parameter cannot have an accessibility modifier. } \ No newline at end of file diff --git a/tests/baselines/reference/parserObjectType6.errors.txt b/tests/baselines/reference/parserObjectType6.errors.txt index afdc6b8f4d8..90841d046a6 100644 --- a/tests/baselines/reference/parserObjectType6.errors.txt +++ b/tests/baselines/reference/parserObjectType6.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/parser/ecmascript5/ObjectTypes/parserObjectType6.ts(3,4): error TS1096: An index signature must have exactly one parameter. tests/cases/conformance/parser/ecmascript5/ObjectTypes/parserObjectType6.ts(2,7): error TS2304: Cannot find name 'B'. +tests/cases/conformance/parser/ecmascript5/ObjectTypes/parserObjectType6.ts(3,4): error TS1096: An index signature must have exactly one parameter. ==== tests/cases/conformance/parser/ecmascript5/ObjectTypes/parserObjectType6.ts (2 errors) ==== diff --git a/tests/baselines/reference/typeParameterConstraints1.errors.txt b/tests/baselines/reference/typeParameterConstraints1.errors.txt index 44261e8d194..f30fd4f6700 100644 --- a/tests/baselines/reference/typeParameterConstraints1.errors.txt +++ b/tests/baselines/reference/typeParameterConstraints1.errors.txt @@ -23,7 +23,7 @@ tests/cases/compiler/typeParameterConstraints1.ts(12,26): error TS2304: Cannot f ~ !!! error TS1110: Type expected. function foo10 (test: T) { } - ~~~ + ~ !!! error TS1110: Type expected. function foo11 (test: T) { } ~~~~ From 408d6f3ea30a90180f725721ab70320112a79bd5 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 10 Dec 2014 19:30:09 -0800 Subject: [PATCH 10/74] Address code review --- src/compiler/binder.ts | 3 --- src/compiler/checker.ts | 3 --- src/compiler/parser.ts | 3 ++- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a458779e52f..dfb5482b09c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -387,9 +387,6 @@ module ts { switch (node.kind) { case SyntaxKind.TypeParameter: bindDeclaration(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false); - if ((node).expression) { - (node).expression.parent = node; - } break; case SyntaxKind.Parameter: if (isBindingPattern((node).name)) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aff559c9261..867161968e4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7019,7 +7019,6 @@ module ts { function checkTypeParameter(node: TypeParameterDeclaration) { // Grammar Checking if (node.expression) { - var sourceFile = getSourceFileOfNode(node); grammarErrorOnFirstToken(node.expression, Diagnostics.Type_expected); } @@ -9879,8 +9878,6 @@ module ts { scanner.setTextPos(pos); scanner.scan(); var start = scanner.getTokenPos(); - scanner.setTextPos(start); - scanner.scan(); return start; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b0a544cb80c..dfce57dba3a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -255,7 +255,8 @@ module ts { child((node).right); case SyntaxKind.TypeParameter: return child((node).name) || - child((node).constraint); + child((node).constraint) || + child((node).expression); case SyntaxKind.Parameter: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: From 7cdf75e1a819a383aa7f1d5b8a5a9ad40382b2ab Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 10 Dec 2014 21:37:05 -0800 Subject: [PATCH 11/74] Move grammar checking: Arrow function --- src/compiler/checker.ts | 11 +++++++---- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 ++- src/compiler/parser.ts | 2 -- tests/baselines/reference/ArrowFunction2.errors.txt | 6 +++--- ...tureWithOptionalParameterAndInitializer.errors.txt | 4 ++-- .../fatarrowfunctionsOptionalArgsErrors4.errors.txt | 2 +- .../reference/parserX_ArrowFunction2.errors.txt | 6 +++--- ...estParameterWithoutAnnotationIsAnyArray.errors.txt | 2 +- .../restParametersOfNonArrayTypes.errors.txt | 2 +- .../restParametersOfNonArrayTypes2.errors.txt | 4 ++-- .../restParametersWithArrayTypeAnnotations.errors.txt | 4 ++-- 12 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 867161968e4..288a74c46a1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6992,7 +6992,10 @@ module ts { case SyntaxKind.ParenthesizedExpression: return checkExpression((node).expression); case SyntaxKind.FunctionExpression: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case SyntaxKind.ArrowFunction: + // Grammar checking + checkGrammarSignatureDeclaration(node); return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case SyntaxKind.TypeOfExpression: return checkTypeOfExpression(node); @@ -9767,7 +9770,7 @@ module ts { } } - function checkGrammarTypeParameterList(signatureDecl: SignatureDeclaration, typeParameters: NodeArray): boolean { + function checkGrammarTypeParameterList(signatureDecl: SignatureDeclaration | Expression, typeParameters: NodeArray): boolean { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -9818,9 +9821,9 @@ module ts { } } - function checkGrammarSignatureDeclaration(node: SignatureDeclaration) { - if (!checkGrammarTypeParameterList(node, node.typeParameters)) { - checkGrammarParameterList(node.parameters); + function checkGrammarSignatureDeclaration(node: SignatureDeclaration | Expression) { + if (!checkGrammarTypeParameterList(node, (node).typeParameters)) { + checkGrammarParameterList((node).parameters); } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 268451c9775..f8d0fdfaa96 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -38,7 +38,7 @@ module ts { _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element.", isEarly: true }, A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, + A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional.", isEarly: true }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 03fad9f5ace..f384157169e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -166,7 +166,8 @@ }, "A rest parameter cannot be optional.": { "category": "Error", - "code": 1047 + "code": 1047, + "isEarly": true }, "A rest parameter cannot have an initializer.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index dfce57dba3a..d25a28f8b7f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4626,8 +4626,6 @@ module ts { function checkNode(node: Node, nodeKind: SyntaxKind): boolean { // Now do node specific checks. switch (nodeKind) { - case SyntaxKind.ArrowFunction: - return checkAnySignatureDeclaration(node); case SyntaxKind.BreakStatement: case SyntaxKind.ContinueStatement: return checkBreakOrContinueStatement(node); diff --git a/tests/baselines/reference/ArrowFunction2.errors.txt b/tests/baselines/reference/ArrowFunction2.errors.txt index 26e1f336cb6..3b9ba21f15a 100644 --- a/tests/baselines/reference/ArrowFunction2.errors.txt +++ b/tests/baselines/reference/ArrowFunction2.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts(1,14): error TS1009: Trailing comma not allowed. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts(1,13): error TS2304: Cannot find name 'b'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts(1,14): error TS1009: Trailing comma not allowed. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts (2 errors) ==== var v = (a: b,) => { - ~ -!!! error TS1009: Trailing comma not allowed. ~ !!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS1009: Trailing comma not allowed. }; \ No newline at end of file diff --git a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt index ecb1c877296..eec5ea18afc 100644 --- a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt +++ b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt @@ -1,12 +1,11 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(3,14): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(4,22): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(5,22): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(15,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(44,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(46,9): error TS1015: Parameter cannot have question mark and initializer. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(5,22): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -14,6 +13,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWith tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(34,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(46,9): error TS1015: Parameter cannot have question mark and initializer. ==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts (16 errors) ==== diff --git a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.errors.txt b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.errors.txt index 8de0eb92a02..fe9df3c2fb3 100644 --- a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.errors.txt +++ b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.errors.txt @@ -3,9 +3,9 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(2,15): error TS1015 tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(3,21): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(4,7): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(4,39): error TS1015: Parameter cannot have question mark and initializer. +tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(6,5): error TS2304: Cannot find name 'foo'. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(17,10): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(19,13): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(6,5): error TS2304: Cannot find name 'foo'. ==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts (8 errors) ==== diff --git a/tests/baselines/reference/parserX_ArrowFunction2.errors.txt b/tests/baselines/reference/parserX_ArrowFunction2.errors.txt index e5b45cef1d0..20b4cb45e45 100644 --- a/tests/baselines/reference/parserX_ArrowFunction2.errors.txt +++ b/tests/baselines/reference/parserX_ArrowFunction2.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_ArrowFunction2.ts(1,14): error TS1009: Trailing comma not allowed. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_ArrowFunction2.ts(1,13): error TS2304: Cannot find name 'b'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_ArrowFunction2.ts(1,14): error TS1009: Trailing comma not allowed. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_ArrowFunction2.ts (2 errors) ==== var v = (a: b,) => { - ~ -!!! error TS1009: Trailing comma not allowed. ~ !!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS1009: Trailing comma not allowed. }; \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt b/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt index 0177f1e9a1c..6685d5fe69f 100644 --- a/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt +++ b/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. ==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts (3 errors) ==== diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt b/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt index 12cbd865d1c..df16e72ea79 100644 --- a/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt +++ b/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(3,14): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(4,22): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,11): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,23): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(8,9): error TS2370: A rest parameter must be of an array type. diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt b/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt index eef052e5cdf..b70c7fb467d 100644 --- a/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt +++ b/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt @@ -1,11 +1,10 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(17,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(27,21): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(44,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(54,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(7,14): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(8,22): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,11): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,26): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(12,9): error TS2370: A rest parameter must be of an array type. @@ -20,6 +19,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfN tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(28,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(34,15): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(35,23): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,11): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,35): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(39,9): error TS2370: A rest parameter must be of an array type. diff --git a/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt b/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt index 06b2caefb9d..05075fc6175 100644 --- a/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt +++ b/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(32,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(40,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(50,21): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(32,11): error TS1014: A rest parameter must be last in a parameter list. ==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts (6 errors) ==== From 547e1296f8ecb686b6f993efbf9bd2163dbb52c4 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 10 Dec 2014 21:37:05 -0800 Subject: [PATCH 12/74] Move grammar checking: Arrow function --- src/compiler/checker.ts | 13 ++++++++----- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 ++- src/compiler/parser.ts | 2 -- tests/baselines/reference/ArrowFunction2.errors.txt | 6 +++--- ...reWithOptionalParameterAndInitializer.errors.txt | 4 ++-- .../fatarrowfunctionsOptionalArgsErrors4.errors.txt | 2 +- .../reference/parserX_ArrowFunction2.errors.txt | 6 +++--- ...tParameterWithoutAnnotationIsAnyArray.errors.txt | 2 +- .../restParametersOfNonArrayTypes.errors.txt | 2 +- .../restParametersOfNonArrayTypes2.errors.txt | 4 ++-- ...estParametersWithArrayTypeAnnotations.errors.txt | 4 ++-- 12 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 867161968e4..7e749dfe07b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6992,7 +6992,10 @@ module ts { case SyntaxKind.ParenthesizedExpression: return checkExpression((node).expression); case SyntaxKind.FunctionExpression: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case SyntaxKind.ArrowFunction: + // Grammar checking + checkGrammarSignatureDeclarationOrArrowFunction(node); return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case SyntaxKind.TypeOfExpression: return checkTypeOfExpression(node); @@ -8755,7 +8758,7 @@ module ts { case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: // Grammar checking - checkGrammarSignatureDeclaration(node) + checkGrammarSignatureDeclarationOrArrowFunction(node) return checkSignatureDeclaration(node); case SyntaxKind.IndexSignature: // Grammar checking @@ -9767,7 +9770,7 @@ module ts { } } - function checkGrammarTypeParameterList(signatureDecl: SignatureDeclaration, typeParameters: NodeArray): boolean { + function checkGrammarTypeParameterList(signatureDecl: SignatureDeclaration | Expression, typeParameters: NodeArray): boolean { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -9818,9 +9821,9 @@ module ts { } } - function checkGrammarSignatureDeclaration(node: SignatureDeclaration) { - if (!checkGrammarTypeParameterList(node, node.typeParameters)) { - checkGrammarParameterList(node.parameters); + function checkGrammarSignatureDeclarationOrArrowFunction(node: SignatureDeclaration | FunctionExpression) { + if (!checkGrammarTypeParameterList(node, (node).typeParameters)) { + checkGrammarParameterList((node).parameters); } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 268451c9775..f8d0fdfaa96 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -38,7 +38,7 @@ module ts { _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element.", isEarly: true }, A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, + A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional.", isEarly: true }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 03fad9f5ace..f384157169e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -166,7 +166,8 @@ }, "A rest parameter cannot be optional.": { "category": "Error", - "code": 1047 + "code": 1047, + "isEarly": true }, "A rest parameter cannot have an initializer.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index dfce57dba3a..d25a28f8b7f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4626,8 +4626,6 @@ module ts { function checkNode(node: Node, nodeKind: SyntaxKind): boolean { // Now do node specific checks. switch (nodeKind) { - case SyntaxKind.ArrowFunction: - return checkAnySignatureDeclaration(node); case SyntaxKind.BreakStatement: case SyntaxKind.ContinueStatement: return checkBreakOrContinueStatement(node); diff --git a/tests/baselines/reference/ArrowFunction2.errors.txt b/tests/baselines/reference/ArrowFunction2.errors.txt index 26e1f336cb6..3b9ba21f15a 100644 --- a/tests/baselines/reference/ArrowFunction2.errors.txt +++ b/tests/baselines/reference/ArrowFunction2.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts(1,14): error TS1009: Trailing comma not allowed. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts(1,13): error TS2304: Cannot find name 'b'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts(1,14): error TS1009: Trailing comma not allowed. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts (2 errors) ==== var v = (a: b,) => { - ~ -!!! error TS1009: Trailing comma not allowed. ~ !!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS1009: Trailing comma not allowed. }; \ No newline at end of file diff --git a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt index ecb1c877296..eec5ea18afc 100644 --- a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt +++ b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt @@ -1,12 +1,11 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(3,14): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(4,22): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(5,22): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(15,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(44,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(46,9): error TS1015: Parameter cannot have question mark and initializer. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(5,22): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -14,6 +13,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWith tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(34,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(46,9): error TS1015: Parameter cannot have question mark and initializer. ==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts (16 errors) ==== diff --git a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.errors.txt b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.errors.txt index 8de0eb92a02..fe9df3c2fb3 100644 --- a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.errors.txt +++ b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.errors.txt @@ -3,9 +3,9 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(2,15): error TS1015 tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(3,21): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(4,7): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(4,39): error TS1015: Parameter cannot have question mark and initializer. +tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(6,5): error TS2304: Cannot find name 'foo'. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(17,10): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(19,13): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts(6,5): error TS2304: Cannot find name 'foo'. ==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors4.ts (8 errors) ==== diff --git a/tests/baselines/reference/parserX_ArrowFunction2.errors.txt b/tests/baselines/reference/parserX_ArrowFunction2.errors.txt index e5b45cef1d0..20b4cb45e45 100644 --- a/tests/baselines/reference/parserX_ArrowFunction2.errors.txt +++ b/tests/baselines/reference/parserX_ArrowFunction2.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_ArrowFunction2.ts(1,14): error TS1009: Trailing comma not allowed. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_ArrowFunction2.ts(1,13): error TS2304: Cannot find name 'b'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_ArrowFunction2.ts(1,14): error TS1009: Trailing comma not allowed. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_ArrowFunction2.ts (2 errors) ==== var v = (a: b,) => { - ~ -!!! error TS1009: Trailing comma not allowed. ~ !!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS1009: Trailing comma not allowed. }; \ No newline at end of file diff --git a/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt b/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt index 0177f1e9a1c..6685d5fe69f 100644 --- a/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt +++ b/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. ==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts (3 errors) ==== diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt b/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt index 12cbd865d1c..df16e72ea79 100644 --- a/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt +++ b/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(3,14): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(4,22): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,11): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,23): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(8,9): error TS2370: A rest parameter must be of an array type. diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt b/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt index eef052e5cdf..b70c7fb467d 100644 --- a/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt +++ b/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt @@ -1,11 +1,10 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(17,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(27,21): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(44,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(54,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(7,14): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(8,22): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,11): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,26): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(12,9): error TS2370: A rest parameter must be of an array type. @@ -20,6 +19,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfN tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(28,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(34,15): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(35,23): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,11): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,35): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(39,9): error TS2370: A rest parameter must be of an array type. diff --git a/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt b/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt index 06b2caefb9d..05075fc6175 100644 --- a/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt +++ b/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(32,11): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(40,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(50,21): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(32,11): error TS1014: A rest parameter must be last in a parameter list. ==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts (6 errors) ==== From b31981c6e98521ced0c42a4eef75312929d0f8e0 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 11:35:51 -0800 Subject: [PATCH 13/74] Address code review --- src/compiler/checker.ts | 29 ++++++++++++++++------------- src/compiler/parser.ts | 1 - 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7e749dfe07b..e5bd7828432 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6397,6 +6397,11 @@ module ts { function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); + // Grammar checking + if (node.kind === SyntaxKind.ArrowFunction) { + checkGrammarFunctionLikeDeclaration(node); + } + // The identityMapper object is used to indicate that function expressions are wildcards if (contextualMapper === identityMapper) { return anyFunctionType; @@ -6992,10 +6997,7 @@ module ts { case SyntaxKind.ParenthesizedExpression: return checkExpression((node).expression); case SyntaxKind.FunctionExpression: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case SyntaxKind.ArrowFunction: - // Grammar checking - checkGrammarSignatureDeclarationOrArrowFunction(node); return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case SyntaxKind.TypeOfExpression: return checkTypeOfExpression(node); @@ -7021,7 +7023,7 @@ module ts { function checkTypeParameter(node: TypeParameterDeclaration) { // Grammar Checking - if (node.expression) { + if (!checkGrammarModifiers(node) && node.expression) { grammarErrorOnFirstToken(node.expression, Diagnostics.Type_expected); } @@ -8758,7 +8760,7 @@ module ts { case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: // Grammar checking - checkGrammarSignatureDeclarationOrArrowFunction(node) + checkGrammarFunctionLikeDeclaration(node) return checkSignatureDeclaration(node); case SyntaxKind.IndexSignature: // Grammar checking @@ -9643,7 +9645,7 @@ module ts { // GRAMMAR CHECKING - function checkModifiers(node: Node): boolean { + function checkGrammarModifiers(node: Node): boolean { switch (node.kind) { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: @@ -9770,14 +9772,14 @@ module ts { } } - function checkGrammarTypeParameterList(signatureDecl: SignatureDeclaration | Expression, typeParameters: NodeArray): boolean { + function checkGrammarTypeParameterList(node: FunctionLikeDeclaration, typeParameters: NodeArray): boolean { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } if (typeParameters && typeParameters.length === 0) { var start = typeParameters.pos - "<".length; - var sourceFile = getSourceFileOfNode(signatureDecl); + var sourceFile = getSourceFileOfNode(node); var end = skipTrivia(sourceFile.text, typeParameters.end) + ">".length; return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty); } @@ -9821,9 +9823,10 @@ module ts { } } - function checkGrammarSignatureDeclarationOrArrowFunction(node: SignatureDeclaration | FunctionExpression) { - if (!checkGrammarTypeParameterList(node, (node).typeParameters)) { - checkGrammarParameterList((node).parameters); + function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration) { + var hasGrammarErrorFromCheckModifierOrTypeParameterList = checkGrammarModifiers(node) ? true : checkGrammarTypeParameterList(node, node.typeParameters); + if (!hasGrammarErrorFromCheckModifierOrTypeParameterList) { + checkGrammarParameterList(node.parameters); } } @@ -9867,8 +9870,8 @@ module ts { } function checkGrammarIndexSignature(node: SignatureDeclaration) { - var hasErrorFromCheckModifiersOrParameters = checkModifiers(node) ? true: checkGrammarIndexSignatureParameters(node); - if (!hasErrorFromCheckModifiersOrParameters) { + var hasGrammarErrorFromCheckModifiersOrParameters = checkGrammarModifiers(node) ? true: checkGrammarIndexSignatureParameters(node); + if (!hasGrammarErrorFromCheckModifiersOrParameters) { checkGrammarForIndexSignatureModifier(node); } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d25a28f8b7f..7e6d8c7a226 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4672,7 +4672,6 @@ module ts { case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); case SyntaxKind.ThrowStatement: return checkThrowStatement(node); - //case SyntaxKind.TupleType: return checkTupleType(node); case SyntaxKind.TypeReference: return checkTypeReference(node); case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); case SyntaxKind.VariableStatement: return checkVariableStatement(node); From 969824439151320c536e2125c2b4d841fe171beb Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 12:06:21 -0800 Subject: [PATCH 14/74] Move grammar checking: callExpression, newExpression --- src/compiler/checker.ts | 37 +++++++++++++++++++ .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 +- src/compiler/parser.ts | 6 +-- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e5bd7828432..c293bebd745 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6248,6 +6248,12 @@ module ts { } function checkCallExpression(node: CallExpression): Type { + // Grammar checking + var hasGrammarErrorFromCheckModifierOrTypeArguments = checkGrammarModifiers(node) ? true : checkGrammarTypeArguments(node, node.typeArguments); + if (!hasGrammarErrorFromCheckModifierOrTypeArguments) { + checkGrammarArguments(node, node.arguments); + } + var signature = getResolvedSignature(node); if (node.expression.kind === SyntaxKind.SuperKeyword) { return voidType; @@ -9876,6 +9882,37 @@ module ts { } } + function checkGrammarForAtLeastOneTypeArgument(node: CallExpression, typeArguments: NodeArray): boolean { + if (typeArguments && typeArguments.length === 0) { + var sourceFile = getSourceFileOfNode(node); + var start = typeArguments.pos - "<".length; + var end = skipTrivia(sourceFile.text, typeArguments.end) + ">".length; + return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Type_argument_list_cannot_be_empty); + } + } + + function checkGrammarTypeArguments(node: CallExpression, typeArguments: NodeArray): boolean { + return checkGrammarForDisallowedTrailingComma(typeArguments) || + checkGrammarForAtLeastOneTypeArgument(node, typeArguments); + } + + function checkGrammarForOmittedArgument(node: CallExpression, arguments: NodeArray): boolean { + if (arguments) { + var sourceFile = getSourceFileOfNode(node); + for (var i = 0, n = arguments.length; i < n; i++) { + var arg = arguments[i]; + if (arg.kind === SyntaxKind.OmittedExpression) { + return grammarErrorAtPos(sourceFile, arg.pos, 0, Diagnostics.Argument_expression_expected); + } + } + } + } + + function checkGrammarArguments(node: CallExpression, arguments: NodeArray): boolean { + return checkGrammarForDisallowedTrailingComma(arguments) || + checkGrammarForOmittedArgument(node, arguments); + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f8d0fdfaa96..c9977d2cc1e 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -64,7 +64,7 @@ module ts { An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: DiagnosticCategory.Error, key: "An index signature must have exactly one parameter.", isEarly: true }, _0_list_cannot_be_empty: { code: 1097, category: DiagnosticCategory.Error, key: "'{0}' list cannot be empty.", isEarly: true }, Type_parameter_list_cannot_be_empty: { code: 1098, category: DiagnosticCategory.Error, key: "Type parameter list cannot be empty.", isEarly: true }, - Type_argument_list_cannot_be_empty: { code: 1099, category: DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, + Type_argument_list_cannot_be_empty: { code: 1099, category: DiagnosticCategory.Error, key: "Type argument list cannot be empty.", isEarly: true }, Invalid_use_of_0_in_strict_mode: { code: 1100, category: DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode.", isEarly: true }, with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode.", isEarly: true }, delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f384157169e..7caf3619cea 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -287,7 +287,8 @@ }, "Type argument list cannot be empty.": { "category": "Error", - "code": 1099 + "code": 1099, + "isEarly": true }, "Invalid use of '{0}' in strict mode.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7e6d8c7a226..a07b9856d70 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4629,9 +4629,9 @@ module ts { case SyntaxKind.BreakStatement: case SyntaxKind.ContinueStatement: return checkBreakOrContinueStatement(node); - case SyntaxKind.CallExpression: - case SyntaxKind.NewExpression: - return checkCallOrNewExpression(node); + //case SyntaxKind.CallExpression: + //case SyntaxKind.NewExpression: + //return checkCallOrNewExpression(node); case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(node); case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); From 907d1d001b0dfd128e8787b6ee7a13a75df750c6 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 12:06:21 -0800 Subject: [PATCH 15/74] Move grammar checking: callExpression, newExpression --- src/compiler/checker.ts | 37 +++++++++++++++++++ .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 +- src/compiler/parser.ts | 6 +-- .../emptyTypeArgumentList.errors.txt | 8 ++-- .../emptyTypeArgumentListWithNew.errors.txt | 8 ++-- .../reference/missingArgument1.errors.txt | 6 +-- ...rserErrorRecovery_ArgumentList5.errors.txt | 6 +-- ...trailingSeparatorInFunctionCall.errors.txt | 14 +++---- 9 files changed, 64 insertions(+), 26 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e5bd7828432..c293bebd745 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6248,6 +6248,12 @@ module ts { } function checkCallExpression(node: CallExpression): Type { + // Grammar checking + var hasGrammarErrorFromCheckModifierOrTypeArguments = checkGrammarModifiers(node) ? true : checkGrammarTypeArguments(node, node.typeArguments); + if (!hasGrammarErrorFromCheckModifierOrTypeArguments) { + checkGrammarArguments(node, node.arguments); + } + var signature = getResolvedSignature(node); if (node.expression.kind === SyntaxKind.SuperKeyword) { return voidType; @@ -9876,6 +9882,37 @@ module ts { } } + function checkGrammarForAtLeastOneTypeArgument(node: CallExpression, typeArguments: NodeArray): boolean { + if (typeArguments && typeArguments.length === 0) { + var sourceFile = getSourceFileOfNode(node); + var start = typeArguments.pos - "<".length; + var end = skipTrivia(sourceFile.text, typeArguments.end) + ">".length; + return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Type_argument_list_cannot_be_empty); + } + } + + function checkGrammarTypeArguments(node: CallExpression, typeArguments: NodeArray): boolean { + return checkGrammarForDisallowedTrailingComma(typeArguments) || + checkGrammarForAtLeastOneTypeArgument(node, typeArguments); + } + + function checkGrammarForOmittedArgument(node: CallExpression, arguments: NodeArray): boolean { + if (arguments) { + var sourceFile = getSourceFileOfNode(node); + for (var i = 0, n = arguments.length; i < n; i++) { + var arg = arguments[i]; + if (arg.kind === SyntaxKind.OmittedExpression) { + return grammarErrorAtPos(sourceFile, arg.pos, 0, Diagnostics.Argument_expression_expected); + } + } + } + } + + function checkGrammarArguments(node: CallExpression, arguments: NodeArray): boolean { + return checkGrammarForDisallowedTrailingComma(arguments) || + checkGrammarForOmittedArgument(node, arguments); + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f8d0fdfaa96..c9977d2cc1e 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -64,7 +64,7 @@ module ts { An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: DiagnosticCategory.Error, key: "An index signature must have exactly one parameter.", isEarly: true }, _0_list_cannot_be_empty: { code: 1097, category: DiagnosticCategory.Error, key: "'{0}' list cannot be empty.", isEarly: true }, Type_parameter_list_cannot_be_empty: { code: 1098, category: DiagnosticCategory.Error, key: "Type parameter list cannot be empty.", isEarly: true }, - Type_argument_list_cannot_be_empty: { code: 1099, category: DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, + Type_argument_list_cannot_be_empty: { code: 1099, category: DiagnosticCategory.Error, key: "Type argument list cannot be empty.", isEarly: true }, Invalid_use_of_0_in_strict_mode: { code: 1100, category: DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode.", isEarly: true }, with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode.", isEarly: true }, delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f384157169e..7caf3619cea 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -287,7 +287,8 @@ }, "Type argument list cannot be empty.": { "category": "Error", - "code": 1099 + "code": 1099, + "isEarly": true }, "Invalid use of '{0}' in strict mode.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7e6d8c7a226..a07b9856d70 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4629,9 +4629,9 @@ module ts { case SyntaxKind.BreakStatement: case SyntaxKind.ContinueStatement: return checkBreakOrContinueStatement(node); - case SyntaxKind.CallExpression: - case SyntaxKind.NewExpression: - return checkCallOrNewExpression(node); + //case SyntaxKind.CallExpression: + //case SyntaxKind.NewExpression: + //return checkCallOrNewExpression(node); case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(node); case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); diff --git a/tests/baselines/reference/emptyTypeArgumentList.errors.txt b/tests/baselines/reference/emptyTypeArgumentList.errors.txt index 51efea14cb1..9f252b127a1 100644 --- a/tests/baselines/reference/emptyTypeArgumentList.errors.txt +++ b/tests/baselines/reference/emptyTypeArgumentList.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/emptyTypeArgumentList.ts(2,4): error TS1099: Type argument list cannot be empty. tests/cases/compiler/emptyTypeArgumentList.ts(2,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/emptyTypeArgumentList.ts(2,4): error TS1099: Type argument list cannot be empty. ==== tests/cases/compiler/emptyTypeArgumentList.ts (2 errors) ==== function foo() { } foo<>(); - ~~ -!!! error TS1099: Type argument list cannot be empty. ~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file +!!! error TS2346: Supplied parameters do not match any signature of call target. + ~~ +!!! error TS1099: Type argument list cannot be empty. \ No newline at end of file diff --git a/tests/baselines/reference/emptyTypeArgumentListWithNew.errors.txt b/tests/baselines/reference/emptyTypeArgumentListWithNew.errors.txt index 538d0abb264..799e35d0d47 100644 --- a/tests/baselines/reference/emptyTypeArgumentListWithNew.errors.txt +++ b/tests/baselines/reference/emptyTypeArgumentListWithNew.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/emptyTypeArgumentListWithNew.ts(2,8): error TS1099: Type argument list cannot be empty. tests/cases/compiler/emptyTypeArgumentListWithNew.ts(2,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/emptyTypeArgumentListWithNew.ts(2,8): error TS1099: Type argument list cannot be empty. ==== tests/cases/compiler/emptyTypeArgumentListWithNew.ts (2 errors) ==== class foo { } new foo<>(); - ~~ -!!! error TS1099: Type argument list cannot be empty. ~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file +!!! error TS2346: Supplied parameters do not match any signature of call target. + ~~ +!!! error TS1099: Type argument list cannot be empty. \ No newline at end of file diff --git a/tests/baselines/reference/missingArgument1.errors.txt b/tests/baselines/reference/missingArgument1.errors.txt index 02911e3c9b5..ba2bb0892f2 100644 --- a/tests/baselines/reference/missingArgument1.errors.txt +++ b/tests/baselines/reference/missingArgument1.errors.txt @@ -1,16 +1,16 @@ -tests/cases/compiler/missingArgument1.ts(1,7): error TS1135: Argument expression expected. tests/cases/compiler/missingArgument1.ts(1,1): error TS2304: Cannot find name 'foo'. tests/cases/compiler/missingArgument1.ts(1,5): error TS2304: Cannot find name 'a'. +tests/cases/compiler/missingArgument1.ts(1,7): error TS1135: Argument expression expected. tests/cases/compiler/missingArgument1.ts(1,8): error TS2304: Cannot find name 'b'. ==== tests/cases/compiler/missingArgument1.ts (4 errors) ==== foo(a,,b); - -!!! error TS1135: Argument expression expected. ~~~ !!! error TS2304: Cannot find name 'foo'. ~ !!! error TS2304: Cannot find name 'a'. + +!!! error TS1135: Argument expression expected. ~ !!! error TS2304: Cannot find name 'b'. \ No newline at end of file diff --git a/tests/baselines/reference/parserErrorRecovery_ArgumentList5.errors.txt b/tests/baselines/reference/parserErrorRecovery_ArgumentList5.errors.txt index 7188df192b8..5113807faa8 100644 --- a/tests/baselines/reference/parserErrorRecovery_ArgumentList5.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ArgumentList5.errors.txt @@ -1,16 +1,16 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArgumentLists/parserErrorRecovery_ArgumentList5.ts(2,9): error TS1009: Trailing comma not allowed. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArgumentLists/parserErrorRecovery_ArgumentList5.ts(2,4): error TS2304: Cannot find name 'bar'. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArgumentLists/parserErrorRecovery_ArgumentList5.ts(2,8): error TS2304: Cannot find name 'a'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArgumentLists/parserErrorRecovery_ArgumentList5.ts(2,9): error TS1009: Trailing comma not allowed. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArgumentLists/parserErrorRecovery_ArgumentList5.ts (3 errors) ==== function foo() { bar(a,) - ~ -!!! error TS1009: Trailing comma not allowed. ~~~ !!! error TS2304: Cannot find name 'bar'. ~ !!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1009: Trailing comma not allowed. return; } \ No newline at end of file diff --git a/tests/baselines/reference/trailingSeparatorInFunctionCall.errors.txt b/tests/baselines/reference/trailingSeparatorInFunctionCall.errors.txt index 986f2dedf6e..76e09a1a4de 100644 --- a/tests/baselines/reference/trailingSeparatorInFunctionCall.errors.txt +++ b/tests/baselines/reference/trailingSeparatorInFunctionCall.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/trailingSeparatorInFunctionCall.ts(4,7): error TS1009: Trailing comma not allowed. -tests/cases/compiler/trailingSeparatorInFunctionCall.ts(9,8): error TS1009: Trailing comma not allowed. tests/cases/compiler/trailingSeparatorInFunctionCall.ts(4,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/trailingSeparatorInFunctionCall.ts(4,7): error TS1009: Trailing comma not allowed. tests/cases/compiler/trailingSeparatorInFunctionCall.ts(9,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/trailingSeparatorInFunctionCall.ts(9,8): error TS1009: Trailing comma not allowed. ==== tests/cases/compiler/trailingSeparatorInFunctionCall.ts (4 errors) ==== @@ -9,16 +9,16 @@ tests/cases/compiler/trailingSeparatorInFunctionCall.ts(9,1): error TS2346: Supp } f(1, 2, ); - ~ -!!! error TS1009: Trailing comma not allowed. ~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. + ~ +!!! error TS1009: Trailing comma not allowed. function f2(x: T, y: T) { } f2(1, 2, ); - ~ -!!! error TS1009: Trailing comma not allowed. ~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file +!!! error TS2346: Supplied parameters do not match any signature of call target. + ~ +!!! error TS1009: Trailing comma not allowed. \ No newline at end of file From c23b6a66e22170dfcfd0351fc788e0a2bdad3ecd Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 12:55:27 -0800 Subject: [PATCH 16/74] Address code review: move checkGrammarAnySignature into checkSignatureDeclaration --- src/compiler/checker.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c293bebd745..0e47a56501b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6405,7 +6405,7 @@ module ts { // Grammar checking if (node.kind === SyntaxKind.ArrowFunction) { - checkGrammarFunctionLikeDeclaration(node); + checkGrammarAnySignatureDeclaration(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -7058,6 +7058,16 @@ module ts { } function checkSignatureDeclaration(node: SignatureDeclaration) { + // Grammar checking + if (node.kind === SyntaxKind.IndexSignature) { + checkGrammarIndexSignature(node); + } + // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled + else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || + node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.ConstructSignature){ + checkGrammarAnySignatureDeclaration(node); + } + checkTypeParameters(node.typeParameters); forEach(node.parameters, checkParameter); if (node.type) { @@ -8765,12 +8775,8 @@ module ts { case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: - // Grammar checking - checkGrammarFunctionLikeDeclaration(node) return checkSignatureDeclaration(node); case SyntaxKind.IndexSignature: - // Grammar checking - checkGrammarIndexSignature(node); return checkSignatureDeclaration(node); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: @@ -9829,7 +9835,7 @@ module ts { } } - function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration) { + function checkGrammarAnySignatureDeclaration(node: FunctionLikeDeclaration) { var hasGrammarErrorFromCheckModifierOrTypeParameterList = checkGrammarModifiers(node) ? true : checkGrammarTypeParameterList(node, node.typeParameters); if (!hasGrammarErrorFromCheckModifierOrTypeParameterList) { checkGrammarParameterList(node.parameters); From d8621069c1dc7823e18306ee6808e30db92c7933 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 12:55:27 -0800 Subject: [PATCH 17/74] Address code review: move checkGrammarAnySignature into checkSignatureDeclaration --- src/compiler/checker.ts | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c293bebd745..8e89eb51343 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6248,11 +6248,8 @@ module ts { } function checkCallExpression(node: CallExpression): Type { - // Grammar checking - var hasGrammarErrorFromCheckModifierOrTypeArguments = checkGrammarModifiers(node) ? true : checkGrammarTypeArguments(node, node.typeArguments); - if (!hasGrammarErrorFromCheckModifierOrTypeArguments) { - checkGrammarArguments(node, node.arguments); - } + // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true + checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); if (node.expression.kind === SyntaxKind.SuperKeyword) { @@ -6405,7 +6402,7 @@ module ts { // Grammar checking if (node.kind === SyntaxKind.ArrowFunction) { - checkGrammarFunctionLikeDeclaration(node); + checkGrammarAnySignatureDeclaration(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -7058,6 +7055,16 @@ module ts { } function checkSignatureDeclaration(node: SignatureDeclaration) { + // Grammar checking + if (node.kind === SyntaxKind.IndexSignature) { + checkGrammarIndexSignature(node); + } + // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled + else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || + node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.ConstructSignature){ + checkGrammarAnySignatureDeclaration(node); + } + checkTypeParameters(node.typeParameters); forEach(node.parameters, checkParameter); if (node.type) { @@ -8765,12 +8772,8 @@ module ts { case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: - // Grammar checking - checkGrammarFunctionLikeDeclaration(node) return checkSignatureDeclaration(node); case SyntaxKind.IndexSignature: - // Grammar checking - checkGrammarIndexSignature(node); return checkSignatureDeclaration(node); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: @@ -9829,11 +9832,9 @@ module ts { } } - function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration) { - var hasGrammarErrorFromCheckModifierOrTypeParameterList = checkGrammarModifiers(node) ? true : checkGrammarTypeParameterList(node, node.typeParameters); - if (!hasGrammarErrorFromCheckModifierOrTypeParameterList) { - checkGrammarParameterList(node.parameters); - } + function checkGrammarAnySignatureDeclaration(node: FunctionLikeDeclaration) { + // Prevent cascading error by short-circuit + checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters); } function checkGrammarIndexSignatureParameters(node: SignatureDeclaration): boolean { @@ -9876,10 +9877,8 @@ module ts { } function checkGrammarIndexSignature(node: SignatureDeclaration) { - var hasGrammarErrorFromCheckModifiersOrParameters = checkGrammarModifiers(node) ? true: checkGrammarIndexSignatureParameters(node); - if (!hasGrammarErrorFromCheckModifiersOrParameters) { - checkGrammarForIndexSignatureModifier(node); - } + // Prevent cascading error by short-circuit + checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); } function checkGrammarForAtLeastOneTypeArgument(node: CallExpression, typeArguments: NodeArray): boolean { From 0d99f1afd5fb36ab62d288bbe333c704c9badc2e Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 14:09:49 -0800 Subject: [PATCH 18/74] Move grammar checking: binaryExpression --- src/compiler/checker.ts | 20 ++++++++++++++++++++ src/compiler/parser.ts | 8 ++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8e89eb51343..c1fe11dc638 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6710,6 +6710,19 @@ module ts { } function checkBinaryExpression(node: BinaryExpression, contextualMapper?: TypeMapper) { + // Grammar checking + if (!checkGrammarModifiers(node)) { + if (node.parserContextFlags & ParserContextFlags.StrictMode) { + if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) { + if (isEvalOrArgumentsIdentifier(node.left)) { + // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) + reportGrammarErrorOfInvalidUseInStrictMode(node.left); + } + } + } + } + var operator = node.operator; if (operator === SyntaxKind.EqualsToken && (node.left.kind === SyntaxKind.ObjectLiteralExpression || node.left.kind === SyntaxKind.ArrayLiteralExpression)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); @@ -9950,6 +9963,13 @@ module ts { } } + function reportGrammarErrorOfInvalidUseInStrictMode(node: Identifier): boolean { + // declarationNameToString cannot be used here since it uses a backreference to 'parent' that is not yet set + var sourceText = getSourceFileOfNode(node).text; + var name = sourceText.substring(skipTrivia(sourceText, node.pos), node.end); + return grammarErrorOnNode(node, Diagnostics.Invalid_use_of_0_in_strict_mode, name); + } + initializeTypeChecker(); return checker; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a07b9856d70..c1ebc5abd4e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -178,7 +178,7 @@ module ts { return node.kind === SyntaxKind.ExpressionStatement && (node).expression.kind === SyntaxKind.StringLiteral; } - function isEvalOrArgumentsIdentifier(node: Node): boolean { + export function isEvalOrArgumentsIdentifier(node: Node): boolean { return node.kind === SyntaxKind.Identifier && (node).text && ((node).text === "eval" || (node).text === "arguments"); @@ -4533,7 +4533,7 @@ module ts { } } - function isLeftHandSideExpression(expr: Expression): boolean { + export function isLeftHandSideExpression(expr: Expression): boolean { if (expr) { switch (expr.kind) { case SyntaxKind.PropertyAccessExpression: @@ -4563,7 +4563,7 @@ module ts { return false; } - function isAssignmentOperator(token: SyntaxKind): boolean { + export function isAssignmentOperator(token: SyntaxKind): boolean { return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment; } @@ -4634,7 +4634,7 @@ module ts { //return checkCallOrNewExpression(node); case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(node); - case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); + //case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); case SyntaxKind.BindingElement: return checkBindingElement(node); case SyntaxKind.CatchClause: return checkCatchClause(node); case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); From b34a453cd4b4ec063f35ba7b9d3faea82d94d54e Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 14:35:55 -0800 Subject: [PATCH 19/74] Move grammar checking: bindingElement --- src/compiler/checker.ts | 16 +++++++++++++++- src/compiler/parser.ts | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c1fe11dc638..1cff181c76c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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(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(node.name); + } + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c1ebc5abd4e..5d3ac16d7ab 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4635,7 +4635,7 @@ module ts { case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(node); //case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); - case SyntaxKind.BindingElement: return checkBindingElement(node); + //case SyntaxKind.BindingElement: return checkBindingElement(node); case SyntaxKind.CatchClause: return checkCatchClause(node); case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); From f13308be31254e48611df64668b3c044a003cf3c Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 14:53:30 -0800 Subject: [PATCH 20/74] Move grammar checking: catchCaluse --- src/compiler/checker.ts | 19 ++++++++++++++++++- src/compiler/parser.ts | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1cff181c76c..97ea6c1fba4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5d3ac16d7ab..f1edf8911bd 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4636,7 +4636,7 @@ module ts { case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(node); //case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); //case SyntaxKind.BindingElement: return checkBindingElement(node); - case SyntaxKind.CatchClause: return checkCatchClause(node); + //case SyntaxKind.CatchClause: return checkCatchClause(node); case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); case SyntaxKind.Constructor: return checkConstructor(node); From 414a4a22950cb6c3b3a7bfd324c6230e710c4bc9 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 15:38:24 -0800 Subject: [PATCH 21/74] Address code review --- src/compiler/checker.ts | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 97ea6c1fba4..67057d1a215 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6402,7 +6402,7 @@ module ts { // Grammar checking if (node.kind === SyntaxKind.ArrowFunction) { - checkGrammarAnySignatureDeclaration(node); + checkGrammarFunctionLikeDeclaration(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -6711,14 +6711,12 @@ module ts { function checkBinaryExpression(node: BinaryExpression, contextualMapper?: TypeMapper) { // Grammar checking - if (!checkGrammarModifiers(node)) { - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) { - if (isEvalOrArgumentsIdentifier(node.left)) { - // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) - reportGrammarErrorOfInvalidUseInStrictMode(node.left); - } + if (node.parserContextFlags & ParserContextFlags.StrictMode) { + if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) { + if (isEvalOrArgumentsIdentifier(node.left)) { + // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) + reportGrammarErrorOfInvalidUseInStrictMode(node.left); } } } @@ -7039,7 +7037,7 @@ module ts { function checkTypeParameter(node: TypeParameterDeclaration) { // Grammar Checking - if (!checkGrammarModifiers(node) && node.expression) { + if (node.expression) { grammarErrorOnFirstToken(node.expression, Diagnostics.Type_expected); } @@ -7075,7 +7073,7 @@ module ts { // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.ConstructSignature){ - checkGrammarAnySignatureDeclaration(node); + checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -9855,7 +9853,7 @@ module ts { } } - function checkGrammarAnySignatureDeclaration(node: FunctionLikeDeclaration) { + function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration) { // Prevent cascading error by short-circuit checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters); } @@ -9936,10 +9934,10 @@ module ts { } 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(node.name); + if (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(node.name); } } @@ -9995,9 +9993,9 @@ module ts { } function reportGrammarErrorOfInvalidUseInStrictMode(node: Identifier): boolean { - // declarationNameToString cannot be used here since it uses a backreference to 'parent' that is not yet set - var sourceText = getSourceFileOfNode(node).text; - var name = sourceText.substring(skipTrivia(sourceText, node.pos), node.end); + //var sourceText = getSourceFileOfNode(node).text; + //var name = sourceText.substring(skipTrivia(sourceText, node.pos), node.end); + var name = declarationNameToString(node); return grammarErrorOnNode(node, Diagnostics.Invalid_use_of_0_in_strict_mode, name); } From 4c91ae0040679ec14c383ac4f7ca9e4419ebf874 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 15:44:52 -0800 Subject: [PATCH 22/74] Move checkGrammarCatchClause into checkTryStatement --- src/compiler/checker.ts | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 67057d1a215..9e24ff87890 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8093,10 +8093,20 @@ module ts { function checkTryStatement(node: TryStatement) { checkBlock(node.tryBlock); - if (node.catchClause) { + var catchClause = node.catchClause; + if (catchClause) { // Grammar checking - checkGrammarCatchClause(node.catchClause); - checkBlock(node.catchClause.block); + if (catchClause.type) { + var sourceFile = getSourceFileOfNode(node); + var colonStart = skipTrivia(sourceFile.text, catchClause.name.end); + grammarErrorAtPos(sourceFile, colonStart, ":".length, Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation); + } + if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(catchClause.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(catchClause.name); + } + checkBlock(catchClause.block); } if (node.finallyBlock) checkBlock(node.finallyBlock); } @@ -9941,19 +9951,6 @@ 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; } From 279aa3946772948f1efccf94c144ad9d353c9d33 Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 11 Dec 2014 16:26:27 -0800 Subject: [PATCH 23/74] Move grammar checking: classDeclaration; there are still errors from checking declare keyword and grammar checking of moduleDeclaration --- src/compiler/checker.ts | 39 +++++++++++++++++++ src/compiler/parser.ts | 4 +- ...ModuleWithStatementsOfEveryKind.errors.txt | 18 ++++----- .../reference/parser618973.errors.txt | 6 +-- .../parserClassDeclaration1.errors.txt | 6 +-- .../parserClassDeclaration2.errors.txt | 6 +-- .../parserClassDeclaration3.errors.txt | 6 +-- .../parserClassDeclaration4.errors.txt | 6 +-- .../parserClassDeclaration5.errors.txt | 6 +-- .../parserClassDeclaration6.errors.txt | 6 +-- 10 files changed, 71 insertions(+), 32 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9e24ff87890..ed34679e794 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8213,6 +8213,45 @@ module ts { } function checkClassDeclaration(node: ClassDeclaration) { + // Grammar checking + var seenExtendsClause = false; + var seenImplementsClause = false; + + if (!checkGrammarModifiers(node) && node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + Debug.assert(i <= 2); + var heritageClause = node.heritageClauses[i]; + + if (heritageClause.token === SyntaxKind.ExtendsKeyword) { + if (seenExtendsClause) { + grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen) + break; + } + + if (seenImplementsClause) { + grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_must_precede_implements_clause); + break; + } + + if (heritageClause.types.length > 1) { + grammarErrorOnFirstToken(heritageClause.types[1], Diagnostics.Classes_can_only_extend_a_single_class); + break; + } + + seenExtendsClause = true; + } + else { + Debug.assert(heritageClause.token === SyntaxKind.ImplementsKeyword); + if (seenImplementsClause) { + grammarErrorOnFirstToken(heritageClause, Diagnostics.implements_clause_already_seen); + break; + } + + seenImplementsClause = true; + } + } + } + checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0); checkTypeParameters(node.typeParameters); checkCollisionWithCapturedThisVariable(node, node.name); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f1edf8911bd..14346dc312c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4637,7 +4637,7 @@ module ts { //case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); //case SyntaxKind.BindingElement: return checkBindingElement(node); //case SyntaxKind.CatchClause: return checkCatchClause(node); - case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); + //case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); case SyntaxKind.Constructor: return checkConstructor(node); case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); @@ -5328,7 +5328,7 @@ module ts { case SyntaxKind.PropertySignature: case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: - case SyntaxKind.ClassDeclaration: + //case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.ModuleDeclaration: case SyntaxKind.EnumDeclaration: diff --git a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt index 101ee0124cc..09647b56771 100644 --- a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt +++ b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt @@ -1,24 +1,24 @@ +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(13,5): error TS1044: 'public' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(19,5): error TS1044: 'public' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(25,5): error TS1044: 'public' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(38,5): error TS1044: 'private' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(44,5): error TS1044: 'private' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(50,5): error TS1044: 'private' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(64,5): error TS1044: 'static' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(70,5): error TS1044: 'static' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(76,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(4,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(6,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(12,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(13,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(15,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(19,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(25,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(29,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(31,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(37,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(38,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(40,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(44,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(50,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(55,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(57,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(63,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(64,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(66,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(70,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(76,5): error TS1044: 'static' modifier cannot appear on a module element. ==== tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts (21 errors) ==== diff --git a/tests/baselines/reference/parser618973.errors.txt b/tests/baselines/reference/parser618973.errors.txt index 83cbfb3eb67..3aa4abcfd70 100644 --- a/tests/baselines/reference/parser618973.errors.txt +++ b/tests/baselines/reference/parser618973.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts(1,8): error TS1030: 'export' modifier already seen. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts(1,21): error TS1148: Cannot compile external modules unless the '--module' flag is provided. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts(1,8): error TS1030: 'export' modifier already seen. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts (2 errors) ==== export export class Foo { - ~~~~~~ -!!! error TS1030: 'export' modifier already seen. ~~~ !!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. + ~~~~~~ +!!! error TS1030: 'export' modifier already seen. public Bar() { } } \ No newline at end of file diff --git a/tests/baselines/reference/parserClassDeclaration1.errors.txt b/tests/baselines/reference/parserClassDeclaration1.errors.txt index 5d148f9c5f6..21ecc68d526 100644 --- a/tests/baselines/reference/parserClassDeclaration1.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts(1,19): error TS1172: 'extends' clause already seen. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts(1,17): error TS2304: Cannot find name 'A'. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts(1,19): error TS1172: 'extends' clause already seen. ==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration1.ts (2 errors) ==== class C extends A extends B { - ~~~~~~~ -!!! error TS1172: 'extends' clause already seen. ~ !!! error TS2304: Cannot find name 'A'. + ~~~~~~~ +!!! error TS1172: 'extends' clause already seen. } \ No newline at end of file diff --git a/tests/baselines/reference/parserClassDeclaration2.errors.txt b/tests/baselines/reference/parserClassDeclaration2.errors.txt index 31887698f3d..18b4e2a0ff2 100644 --- a/tests/baselines/reference/parserClassDeclaration2.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts(1,22): error TS1175: 'implements' clause already seen. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts(1,20): error TS2304: Cannot find name 'A'. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts(1,22): error TS1175: 'implements' clause already seen. ==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration2.ts (2 errors) ==== class C implements A implements B { - ~~~~~~~~~~ -!!! error TS1175: 'implements' clause already seen. ~ !!! error TS2304: Cannot find name 'A'. + ~~~~~~~~~~ +!!! error TS1175: 'implements' clause already seen. } \ No newline at end of file diff --git a/tests/baselines/reference/parserClassDeclaration3.errors.txt b/tests/baselines/reference/parserClassDeclaration3.errors.txt index 38cac10f4df..83a3dc7713a 100644 --- a/tests/baselines/reference/parserClassDeclaration3.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration3.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts(1,22): error TS1173: 'extends' clause must precede 'implements' clause. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts(1,20): error TS2304: Cannot find name 'A'. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts(1,22): error TS1173: 'extends' clause must precede 'implements' clause. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts(1,30): error TS2304: Cannot find name 'B'. ==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration3.ts (3 errors) ==== class C implements A extends B { - ~~~~~~~ -!!! error TS1173: 'extends' clause must precede 'implements' clause. ~ !!! error TS2304: Cannot find name 'A'. + ~~~~~~~ +!!! error TS1173: 'extends' clause must precede 'implements' clause. ~ !!! error TS2304: Cannot find name 'B'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserClassDeclaration4.errors.txt b/tests/baselines/reference/parserClassDeclaration4.errors.txt index 27808412228..b285c13fec5 100644 --- a/tests/baselines/reference/parserClassDeclaration4.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration4.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts(1,32): error TS1172: 'extends' clause already seen. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts(1,17): error TS2304: Cannot find name 'A'. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts(1,30): error TS2304: Cannot find name 'B'. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts(1,32): error TS1172: 'extends' clause already seen. ==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration4.ts (3 errors) ==== class C extends A implements B extends C { - ~~~~~~~ -!!! error TS1172: 'extends' clause already seen. ~ !!! error TS2304: Cannot find name 'A'. ~ !!! error TS2304: Cannot find name 'B'. + ~~~~~~~ +!!! error TS1172: 'extends' clause already seen. } \ No newline at end of file diff --git a/tests/baselines/reference/parserClassDeclaration5.errors.txt b/tests/baselines/reference/parserClassDeclaration5.errors.txt index 8cd90d61dee..fca4b0f8fdf 100644 --- a/tests/baselines/reference/parserClassDeclaration5.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration5.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,32): error TS1175: 'implements' clause already seen. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,17): error TS2304: Cannot find name 'A'. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,30): error TS2304: Cannot find name 'B'. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts(1,32): error TS1175: 'implements' clause already seen. ==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration5.ts (3 errors) ==== class C extends A implements B implements C { - ~~~~~~~~~~ -!!! error TS1175: 'implements' clause already seen. ~ !!! error TS2304: Cannot find name 'A'. ~ !!! error TS2304: Cannot find name 'B'. + ~~~~~~~~~~ +!!! error TS1175: 'implements' clause already seen. } \ No newline at end of file diff --git a/tests/baselines/reference/parserClassDeclaration6.errors.txt b/tests/baselines/reference/parserClassDeclaration6.errors.txt index af0139d4fe1..b7b42463e1f 100644 --- a/tests/baselines/reference/parserClassDeclaration6.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts(1,20): error TS1174: Classes can only extend a single class. tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts(1,17): error TS2304: Cannot find name 'A'. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts(1,20): error TS1174: Classes can only extend a single class. ==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration6.ts (2 errors) ==== class C extends A, B { - ~ -!!! error TS1174: Classes can only extend a single class. ~ !!! error TS2304: Cannot find name 'A'. + ~ +!!! error TS1174: Classes can only extend a single class. } \ No newline at end of file From 6251127152d8837391c91f86b4cc6e1ad153b6dc Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 00:11:59 -0800 Subject: [PATCH 24/74] Move grammar checking : computedPropertyName; there is still error from grammar check on ambient context and generator --- src/compiler/checker.ts | 18 ++++++++++++++++++ src/compiler/parser.ts | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ed34679e794..8d930bbfb72 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5357,6 +5357,14 @@ module ts { var properties: SymbolTable = {}; var contextualType = getContextualType(node); var typeFlags: TypeFlags; + + // Grammar checking for computedPropertyName + forEach(node.properties, property => { + if (property.name && property.name.kind === SyntaxKind.ComputedPropertyName) { + checkGrammarComputedPropertyName(property.name); + } + }); + for (var id in members) { if (hasProperty(members, id)) { var member = members[id]; @@ -5405,6 +5413,7 @@ module ts { properties[member.name] = member; } } + var stringIndexType = getIndexType(IndexKind.String); var numberIndexType = getIndexType(IndexKind.Number); var result = createAnonymousType(node.symbol, properties, emptyArray, emptyArray, stringIndexType, numberIndexType); @@ -9990,6 +9999,15 @@ module ts { } } + function checkGrammarComputedPropertyName(node: ComputedPropertyName): void { + if (compilerOptions.target < ScriptTarget.ES6) { + grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + else if (node.expression.kind === SyntaxKind.BinaryExpression && (node.expression).operator === SyntaxKind.CommaToken) { + grammarErrorOnNode(node.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + } + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 14346dc312c..2d0e085f7f1 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4638,7 +4638,7 @@ module ts { //case SyntaxKind.BindingElement: return checkBindingElement(node); //case SyntaxKind.CatchClause: return checkCatchClause(node); //case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); - case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); + //case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); case SyntaxKind.Constructor: return checkConstructor(node); case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); From 04c9cbfbd4805e50323cc0d8f299133ed87d7eed Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 10:13:47 -0800 Subject: [PATCH 25/74] Address code review --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8d930bbfb72..91f806e0518 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5360,7 +5360,7 @@ module ts { // Grammar checking for computedPropertyName forEach(node.properties, property => { - if (property.name && property.name.kind === SyntaxKind.ComputedPropertyName) { + if (property.name.kind === SyntaxKind.ComputedPropertyName) { checkGrammarComputedPropertyName(property.name); } }); From 867e2a8b6f0e76207cbae1e903e1500c8199a44e Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 11 Dec 2014 16:49:24 -0800 Subject: [PATCH 26/74] Disable computed properties in TypeScript 1.4 Conflicts: src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json --- .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 ++ src/compiler/parser.ts | 4 ++ .../FunctionDeclaration8_es6.errors.txt | 4 +- .../computedPropertyNames1.errors.txt | 13 +++++ .../reference/computedPropertyNames1.js | 14 ------ .../reference/computedPropertyNames1.types | 12 ----- .../computedPropertyNames2.errors.txt | 20 +++++++- .../reference/computedPropertyNames2.js | 48 ------------------- .../computedPropertyNames3.errors.txt | 20 +++++++- .../reference/computedPropertyNames3.js | 47 ------------------ ...omputedPropertyNamesOnOverloads.errors.txt | 5 +- .../parserComputedPropertyName12.errors.txt | 9 ++++ .../reference/parserComputedPropertyName12.js | 13 ----- .../parserComputedPropertyName12.types | 7 --- .../parserComputedPropertyName17.errors.txt | 7 +++ .../reference/parserComputedPropertyName17.js | 6 --- .../parserComputedPropertyName17.types | 7 --- .../parserComputedPropertyName2.errors.txt | 7 +++ .../reference/parserComputedPropertyName2.js | 5 -- .../parserComputedPropertyName2.types | 6 --- .../parserComputedPropertyName24.errors.txt | 9 ++++ .../reference/parserComputedPropertyName24.js | 17 ------- .../parserComputedPropertyName24.types | 8 ---- .../parserComputedPropertyName3.errors.txt | 7 +++ .../reference/parserComputedPropertyName3.js | 6 --- .../parserComputedPropertyName3.types | 6 --- .../parserComputedPropertyName35.errors.txt | 6 +-- .../parserComputedPropertyName37.errors.txt | 9 ++++ .../reference/parserComputedPropertyName37.js | 9 ---- .../parserComputedPropertyName37.types | 9 ---- .../parserComputedPropertyName38.errors.txt | 9 ++++ .../reference/parserComputedPropertyName38.js | 13 ----- .../parserComputedPropertyName38.types | 7 --- .../parserComputedPropertyName4.errors.txt | 7 +++ .../reference/parserComputedPropertyName4.js | 6 --- .../parserComputedPropertyName4.types | 6 --- .../parserComputedPropertyName40.errors.txt | 9 ++++ .../reference/parserComputedPropertyName40.js | 13 ----- .../parserComputedPropertyName40.types | 8 ---- .../parserComputedPropertyName41.errors.txt | 9 ++++ .../reference/parserComputedPropertyName41.js | 9 ---- .../parserComputedPropertyName41.types | 9 ---- .../parserComputedPropertyName6.errors.txt | 10 ++++ .../reference/parserComputedPropertyName6.js | 5 -- .../parserComputedPropertyName6.types | 9 ---- .../parserES5ComputedPropertyName2.errors.txt | 4 +- .../parserES5ComputedPropertyName3.errors.txt | 4 +- .../parserES5ComputedPropertyName4.errors.txt | 4 +- 49 files changed, 167 insertions(+), 319 deletions(-) create mode 100644 tests/baselines/reference/computedPropertyNames1.errors.txt delete mode 100644 tests/baselines/reference/computedPropertyNames1.js delete mode 100644 tests/baselines/reference/computedPropertyNames1.types delete mode 100644 tests/baselines/reference/computedPropertyNames2.js delete mode 100644 tests/baselines/reference/computedPropertyNames3.js create mode 100644 tests/baselines/reference/parserComputedPropertyName12.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName12.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName12.types create mode 100644 tests/baselines/reference/parserComputedPropertyName17.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName17.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName17.types create mode 100644 tests/baselines/reference/parserComputedPropertyName2.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName2.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName2.types create mode 100644 tests/baselines/reference/parserComputedPropertyName24.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName24.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName24.types create mode 100644 tests/baselines/reference/parserComputedPropertyName3.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName3.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName3.types create mode 100644 tests/baselines/reference/parserComputedPropertyName37.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName37.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName37.types create mode 100644 tests/baselines/reference/parserComputedPropertyName38.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName38.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName38.types create mode 100644 tests/baselines/reference/parserComputedPropertyName4.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName4.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName4.types create mode 100644 tests/baselines/reference/parserComputedPropertyName40.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName40.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName40.types create mode 100644 tests/baselines/reference/parserComputedPropertyName41.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName41.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName41.types create mode 100644 tests/baselines/reference/parserComputedPropertyName6.errors.txt delete mode 100644 tests/baselines/reference/parserComputedPropertyName6.js delete mode 100644 tests/baselines/reference/parserComputedPropertyName6.types diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index c9977d2cc1e..60f7dd8588d 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -435,5 +435,6 @@ module ts { You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported.", isEarly: true }, generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "'generators' are not currently supported.", isEarly: true }, + Computed_property_names_are_not_currently_supported: { code: 9002, category: DiagnosticCategory.Error, key: "Computed property names are not currently supported.", isEarly: true }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7caf3619cea..eb8cf807c97 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1826,5 +1826,9 @@ "category": "Error", "code": 9001, "isEarly": true + }, + "Computed property names are not currently supported.": { + "category": "Error", + "code": 9002, } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 2d0e085f7f1..7f8d766cc93 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5552,6 +5552,10 @@ module ts { } function checkComputedPropertyName(node: ComputedPropertyName) { + // Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4 + // Once full support is added, remove this error. + return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_not_currently_supported); + if (languageVersion < ScriptTarget.ES6) { return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); } diff --git a/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt index 5232c8f1608..08d151203c9 100644 --- a/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS9002: Computed property names are not currently supported. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (1 errors) ==== var v = { [yield]: foo } ~~~~~~~ -!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames1.errors.txt b/tests/baselines/reference/computedPropertyNames1.errors.txt new file mode 100644 index 00000000000..02abbcd6b2d --- /dev/null +++ b/tests/baselines/reference/computedPropertyNames1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts(2,9): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts(3,9): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts (2 errors) ==== + var v = { + get [0 + 1]() { return 0 }, + ~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. + set [0 + 1](v: string) { } //No error + ~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. + } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames1.js b/tests/baselines/reference/computedPropertyNames1.js deleted file mode 100644 index 8f3e448d698..00000000000 --- a/tests/baselines/reference/computedPropertyNames1.js +++ /dev/null @@ -1,14 +0,0 @@ -//// [computedPropertyNames1.ts] -var v = { - get [0 + 1]() { return 0 }, - set [0 + 1](v: string) { } //No error -} - -//// [computedPropertyNames1.js] -var v = { - get [0 + 1]() { - return 0; - }, - set [0 + 1](v) { - } //No error -}; diff --git a/tests/baselines/reference/computedPropertyNames1.types b/tests/baselines/reference/computedPropertyNames1.types deleted file mode 100644 index b44aa3c69d0..00000000000 --- a/tests/baselines/reference/computedPropertyNames1.types +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts === -var v = { ->v : {} ->{ get [0 + 1]() { return 0 }, set [0 + 1](v: string) { } //No error} : {} - - get [0 + 1]() { return 0 }, ->0 + 1 : number - - set [0 + 1](v: string) { } //No error ->0 + 1 : number ->v : string -} diff --git a/tests/baselines/reference/computedPropertyNames2.errors.txt b/tests/baselines/reference/computedPropertyNames2.errors.txt index d0fd1de4576..e7cc84a8f6e 100644 --- a/tests/baselines/reference/computedPropertyNames2.errors.txt +++ b/tests/baselines/reference/computedPropertyNames2.errors.txt @@ -1,19 +1,37 @@ +tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(4,5): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(5,12): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(7,9): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(9,16): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (2 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (8 errors) ==== var methodName = "method"; var accessorName = "accessor"; class C { [methodName]() { } + ~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. static [methodName]() { } + ~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. get [accessorName]() { } ~~~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. + ~~~~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. set [accessorName](v) { } + ~~~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. static get [accessorName]() { } ~~~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. + ~~~~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. static set [accessorName](v) { } + ~~~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames2.js b/tests/baselines/reference/computedPropertyNames2.js deleted file mode 100644 index 78d53ef94fc..00000000000 --- a/tests/baselines/reference/computedPropertyNames2.js +++ /dev/null @@ -1,48 +0,0 @@ -//// [computedPropertyNames2.ts] -var methodName = "method"; -var accessorName = "accessor"; -class C { - [methodName]() { } - static [methodName]() { } - get [accessorName]() { } - set [accessorName](v) { } - static get [accessorName]() { } - static set [accessorName](v) { } -} - -//// [computedPropertyNames2.js] -var methodName = "method"; -var accessorName = "accessor"; -var C = (function () { - function C() { - } - C.prototype[methodName] = function () { - }; - C[methodName] = function () { - }; - Object.defineProperty(C.prototype, accessorName, { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, accessorName, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, accessorName, { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, accessorName, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); diff --git a/tests/baselines/reference/computedPropertyNames3.errors.txt b/tests/baselines/reference/computedPropertyNames3.errors.txt index 37a4ddaf1c0..a1d6e09421b 100644 --- a/tests/baselines/reference/computedPropertyNames3.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3.errors.txt @@ -1,18 +1,36 @@ +tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(3,5): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(4,12): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(6,9): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(8,16): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (2 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (8 errors) ==== var id; class C { [0 + 1]() { } + ~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. static [() => { }]() { } + ~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. get [delete id]() { } ~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. + ~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. set [[0, 1]](v) { } + ~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. static get [""]() { } ~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. + ~~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. static set [id.toString()](v) { } + ~~~~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames3.js b/tests/baselines/reference/computedPropertyNames3.js deleted file mode 100644 index fbd76bf48fc..00000000000 --- a/tests/baselines/reference/computedPropertyNames3.js +++ /dev/null @@ -1,47 +0,0 @@ -//// [computedPropertyNames3.ts] -var id; -class C { - [0 + 1]() { } - static [() => { }]() { } - get [delete id]() { } - set [[0, 1]](v) { } - static get [""]() { } - static set [id.toString()](v) { } -} - -//// [computedPropertyNames3.js] -var id; -var C = (function () { - function C() { - } - C.prototype[0 + 1] = function () { - }; - C[function () { - }] = function () { - }; - Object.defineProperty(C.prototype, delete id, { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, [0, 1], { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, "", { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, id.toString(), { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt index b3c2957a13f..6329ab39f0f 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt @@ -1,8 +1,9 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(4,5): error TS1168: Computed property names are not allowed in method overloads. tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(5,5): error TS1168: Computed property names are not allowed in method overloads. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(6,5): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (2 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (3 errors) ==== var methodName = "method"; var accessorName = "accessor"; class C { @@ -13,4 +14,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads. ~~~~~~~~~~~~ !!! error TS1168: Computed property names are not allowed in method overloads. [methodName](v?: string) { } + ~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName12.errors.txt b/tests/baselines/reference/parserComputedPropertyName12.errors.txt new file mode 100644 index 00000000000..c028275369d --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName12.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts(2,4): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts (1 errors) ==== + class C { + [e]() { } + ~~~ +!!! error TS9002: Computed property names are not currently supported. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName12.js b/tests/baselines/reference/parserComputedPropertyName12.js deleted file mode 100644 index 96e62b626e7..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName12.js +++ /dev/null @@ -1,13 +0,0 @@ -//// [parserComputedPropertyName12.ts] -class C { - [e]() { } -} - -//// [parserComputedPropertyName12.js] -var C = (function () { - function C() { - } - C.prototype[e] = function () { - }; - return C; -})(); diff --git a/tests/baselines/reference/parserComputedPropertyName12.types b/tests/baselines/reference/parserComputedPropertyName12.types deleted file mode 100644 index fcc96bc4d51..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName12.types +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName12.ts === -class C { ->C : C - - [e]() { } ->e : unknown -} diff --git a/tests/baselines/reference/parserComputedPropertyName17.errors.txt b/tests/baselines/reference/parserComputedPropertyName17.errors.txt new file mode 100644 index 00000000000..f8b1a4866e8 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName17.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts(1,15): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts (1 errors) ==== + var v = { set [e](v) { } } + ~~~ +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName17.js b/tests/baselines/reference/parserComputedPropertyName17.js deleted file mode 100644 index 98d61ab8bca..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName17.js +++ /dev/null @@ -1,6 +0,0 @@ -//// [parserComputedPropertyName17.ts] -var v = { set [e](v) { } } - -//// [parserComputedPropertyName17.js] -var v = { set [e](v) { -} }; diff --git a/tests/baselines/reference/parserComputedPropertyName17.types b/tests/baselines/reference/parserComputedPropertyName17.types deleted file mode 100644 index 8ae109dda37..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName17.types +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName17.ts === -var v = { set [e](v) { } } ->v : {} ->{ set [e](v) { } } : {} ->e : unknown ->v : any - diff --git a/tests/baselines/reference/parserComputedPropertyName2.errors.txt b/tests/baselines/reference/parserComputedPropertyName2.errors.txt new file mode 100644 index 00000000000..9eb6cdd6004 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName2.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts(1,11): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts (1 errors) ==== + var v = { [e]: 1 }; + ~~~ +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName2.js b/tests/baselines/reference/parserComputedPropertyName2.js deleted file mode 100644 index f3c41f963f5..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName2.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [parserComputedPropertyName2.ts] -var v = { [e]: 1 }; - -//// [parserComputedPropertyName2.js] -var v = { [e]: 1 }; diff --git a/tests/baselines/reference/parserComputedPropertyName2.types b/tests/baselines/reference/parserComputedPropertyName2.types deleted file mode 100644 index 8e533282e28..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName2.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName2.ts === -var v = { [e]: 1 }; ->v : {} ->{ [e]: 1 } : {} ->e : unknown - diff --git a/tests/baselines/reference/parserComputedPropertyName24.errors.txt b/tests/baselines/reference/parserComputedPropertyName24.errors.txt new file mode 100644 index 00000000000..fa7280a93e7 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName24.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts(2,9): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts (1 errors) ==== + class C { + set [e](v) { } + ~~~ +!!! error TS9002: Computed property names are not currently supported. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName24.js b/tests/baselines/reference/parserComputedPropertyName24.js deleted file mode 100644 index 0b9467fb26d..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName24.js +++ /dev/null @@ -1,17 +0,0 @@ -//// [parserComputedPropertyName24.ts] -class C { - set [e](v) { } -} - -//// [parserComputedPropertyName24.js] -var C = (function () { - function C() { - } - Object.defineProperty(C.prototype, e, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); diff --git a/tests/baselines/reference/parserComputedPropertyName24.types b/tests/baselines/reference/parserComputedPropertyName24.types deleted file mode 100644 index d2de5244057..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName24.types +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName24.ts === -class C { ->C : C - - set [e](v) { } ->e : unknown ->v : any -} diff --git a/tests/baselines/reference/parserComputedPropertyName3.errors.txt b/tests/baselines/reference/parserComputedPropertyName3.errors.txt new file mode 100644 index 00000000000..b13f453cb89 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName3.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts(1,11): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts (1 errors) ==== + var v = { [e]() { } }; + ~~~ +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName3.js b/tests/baselines/reference/parserComputedPropertyName3.js deleted file mode 100644 index 2e73fe87d3a..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName3.js +++ /dev/null @@ -1,6 +0,0 @@ -//// [parserComputedPropertyName3.ts] -var v = { [e]() { } }; - -//// [parserComputedPropertyName3.js] -var v = { [e]() { -} }; diff --git a/tests/baselines/reference/parserComputedPropertyName3.types b/tests/baselines/reference/parserComputedPropertyName3.types deleted file mode 100644 index 8a5cfafbd40..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName3.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName3.ts === -var v = { [e]() { } }; ->v : {} ->{ [e]() { } } : {} ->e : unknown - diff --git a/tests/baselines/reference/parserComputedPropertyName35.errors.txt b/tests/baselines/reference/parserComputedPropertyName35.errors.txt index e603d1c73fd..d68f0eb1ec7 100644 --- a/tests/baselines/reference/parserComputedPropertyName35.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName35.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts(2,6): error TS1171: A comma expression is not allowed in a computed property name. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts(2,5): error TS9002: Computed property names are not currently supported. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName35.ts (1 errors) ==== var x = { [0, 1]: { } - ~~~~ -!!! error TS1171: A comma expression is not allowed in a computed property name. + ~~~~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName37.errors.txt b/tests/baselines/reference/parserComputedPropertyName37.errors.txt new file mode 100644 index 00000000000..fa1acd5dbe0 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName37.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts(2,5): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts (1 errors) ==== + var v = { + [public]: 0 + ~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. + }; \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName37.js b/tests/baselines/reference/parserComputedPropertyName37.js deleted file mode 100644 index eb16d5ade37..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName37.js +++ /dev/null @@ -1,9 +0,0 @@ -//// [parserComputedPropertyName37.ts] -var v = { - [public]: 0 -}; - -//// [parserComputedPropertyName37.js] -var v = { - [public]: 0 -}; diff --git a/tests/baselines/reference/parserComputedPropertyName37.types b/tests/baselines/reference/parserComputedPropertyName37.types deleted file mode 100644 index ebcd0ca276c..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName37.types +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName37.ts === -var v = { ->v : {} ->{ [public]: 0} : {} - - [public]: 0 ->public : unknown - -}; diff --git a/tests/baselines/reference/parserComputedPropertyName38.errors.txt b/tests/baselines/reference/parserComputedPropertyName38.errors.txt new file mode 100644 index 00000000000..910a907ee0f --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName38.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,5): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts (1 errors) ==== + class C { + [public]() { } + ~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName38.js b/tests/baselines/reference/parserComputedPropertyName38.js deleted file mode 100644 index 487ff4078fd..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName38.js +++ /dev/null @@ -1,13 +0,0 @@ -//// [parserComputedPropertyName38.ts] -class C { - [public]() { } -} - -//// [parserComputedPropertyName38.js] -var C = (function () { - function C() { - } - C.prototype[public] = function () { - }; - return C; -})(); diff --git a/tests/baselines/reference/parserComputedPropertyName38.types b/tests/baselines/reference/parserComputedPropertyName38.types deleted file mode 100644 index c77b9fcc67f..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName38.types +++ /dev/null @@ -1,7 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts === -class C { ->C : C - - [public]() { } ->public : unknown -} diff --git a/tests/baselines/reference/parserComputedPropertyName4.errors.txt b/tests/baselines/reference/parserComputedPropertyName4.errors.txt new file mode 100644 index 00000000000..c1137b15872 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName4.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts(1,15): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts (1 errors) ==== + var v = { get [e]() { } }; + ~~~ +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName4.js b/tests/baselines/reference/parserComputedPropertyName4.js deleted file mode 100644 index a88545566e6..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName4.js +++ /dev/null @@ -1,6 +0,0 @@ -//// [parserComputedPropertyName4.ts] -var v = { get [e]() { } }; - -//// [parserComputedPropertyName4.js] -var v = { get [e]() { -} }; diff --git a/tests/baselines/reference/parserComputedPropertyName4.types b/tests/baselines/reference/parserComputedPropertyName4.types deleted file mode 100644 index 32a1b44efeb..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName4.types +++ /dev/null @@ -1,6 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName4.ts === -var v = { get [e]() { } }; ->v : {} ->{ get [e]() { } } : {} ->e : unknown - diff --git a/tests/baselines/reference/parserComputedPropertyName40.errors.txt b/tests/baselines/reference/parserComputedPropertyName40.errors.txt new file mode 100644 index 00000000000..93be0ad51b7 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName40.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts(2,5): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts (1 errors) ==== + class C { + [a ? "" : ""]() {} + ~~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName40.js b/tests/baselines/reference/parserComputedPropertyName40.js deleted file mode 100644 index 5f6381360fc..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName40.js +++ /dev/null @@ -1,13 +0,0 @@ -//// [parserComputedPropertyName40.ts] -class C { - [a ? "" : ""]() {} -} - -//// [parserComputedPropertyName40.js] -var C = (function () { - function C() { - } - C.prototype[a ? "" : ""] = function () { - }; - return C; -})(); diff --git a/tests/baselines/reference/parserComputedPropertyName40.types b/tests/baselines/reference/parserComputedPropertyName40.types deleted file mode 100644 index 1b0b3ae49f0..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName40.types +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName40.ts === -class C { ->C : C - - [a ? "" : ""]() {} ->a ? "" : "" : string ->a : unknown -} diff --git a/tests/baselines/reference/parserComputedPropertyName41.errors.txt b/tests/baselines/reference/parserComputedPropertyName41.errors.txt new file mode 100644 index 00000000000..eb5e9a9ebbf --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName41.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts(2,5): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts (1 errors) ==== + var v = { + [0 in []]: true + ~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. + } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName41.js b/tests/baselines/reference/parserComputedPropertyName41.js deleted file mode 100644 index b19cc3e7b3f..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName41.js +++ /dev/null @@ -1,9 +0,0 @@ -//// [parserComputedPropertyName41.ts] -var v = { - [0 in []]: true -} - -//// [parserComputedPropertyName41.js] -var v = { - [0 in []]: true -}; diff --git a/tests/baselines/reference/parserComputedPropertyName41.types b/tests/baselines/reference/parserComputedPropertyName41.types deleted file mode 100644 index 468a44e6b9e..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName41.types +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName41.ts === -var v = { ->v : {} ->{ [0 in []]: true} : {} - - [0 in []]: true ->0 in [] : boolean ->[] : undefined[] -} diff --git a/tests/baselines/reference/parserComputedPropertyName6.errors.txt b/tests/baselines/reference/parserComputedPropertyName6.errors.txt new file mode 100644 index 00000000000..893bf3da719 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts(1,11): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts(1,19): error TS9002: Computed property names are not currently supported. + + +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts (2 errors) ==== + var v = { [e]: 1, [e + e]: 2 }; + ~~~ +!!! error TS9002: Computed property names are not currently supported. + ~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName6.js b/tests/baselines/reference/parserComputedPropertyName6.js deleted file mode 100644 index b60ad66a9d8..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName6.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [parserComputedPropertyName6.ts] -var v = { [e]: 1, [e + e]: 2 }; - -//// [parserComputedPropertyName6.js] -var v = { [e]: 1, [e + e]: 2 }; diff --git a/tests/baselines/reference/parserComputedPropertyName6.types b/tests/baselines/reference/parserComputedPropertyName6.types deleted file mode 100644 index 5fa7e79c32c..00000000000 --- a/tests/baselines/reference/parserComputedPropertyName6.types +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName6.ts === -var v = { [e]: 1, [e + e]: 2 }; ->v : {} ->{ [e]: 1, [e + e]: 2 } : {} ->e : unknown ->e + e : any ->e : unknown ->e : unknown - diff --git a/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt index dc7d7e7ba30..7b6b74b8fd8 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName2.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts(1,11): error TS9002: Computed property names are not currently supported. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName2.ts (1 errors) ==== var v = { [e]: 1 }; ~~~ -!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt index 376c1a29ae4..669fd190265 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName3.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts(1,11): error TS9002: Computed property names are not currently supported. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName3.ts (1 errors) ==== var v = { [e]() { } }; ~~~ -!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt index e0b816f157c..af0c6e858ad 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName4.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,15): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts(1,15): error TS9002: Computed property names are not currently supported. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName4.ts (1 errors) ==== var v = { get [e]() { } }; ~~~ -!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file From 8be44f111c874270bbd59744271dee4ec4e00038 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 11 Dec 2014 17:22:22 -0800 Subject: [PATCH 27/74] Don't quote the word 'generators' in error messages Conflicts: src/compiler/diagnosticInformationMap.generated.ts --- src/compiler/diagnosticInformationMap.generated.ts | 6 +++--- src/compiler/diagnosticMessages.json | 2 +- src/compiler/parser.ts | 2 +- .../reference/FunctionDeclaration10_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration11_es6.errors.txt | 4 ++-- .../reference/FunctionDeclaration13_es6.errors.txt | 4 ++-- .../baselines/reference/FunctionDeclaration1_es6.errors.txt | 4 ++-- .../baselines/reference/FunctionDeclaration6_es6.errors.txt | 4 ++-- .../baselines/reference/FunctionDeclaration7_es6.errors.txt | 4 ++-- .../baselines/reference/FunctionDeclaration9_es6.errors.txt | 4 ++-- .../baselines/reference/FunctionExpression1_es6.errors.txt | 4 ++-- .../baselines/reference/FunctionExpression2_es6.errors.txt | 4 ++-- .../reference/FunctionPropertyAssignments1_es6.errors.txt | 4 ++-- .../reference/FunctionPropertyAssignments5_es6.errors.txt | 4 ++-- .../reference/MemberFunctionDeclaration1_es6.errors.txt | 4 ++-- .../reference/MemberFunctionDeclaration2_es6.errors.txt | 4 ++-- .../reference/MemberFunctionDeclaration3_es6.errors.txt | 4 ++-- .../reference/MemberFunctionDeclaration7_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression10_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression11_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression13_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression16_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression19_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression3_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression4_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression6_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression7_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression8_es6.errors.txt | 4 ++-- tests/baselines/reference/YieldExpression9_es6.errors.txt | 4 ++-- .../reference/templateStringInYieldKeyword.errors.txt | 4 ++-- .../templateStringWithEmbeddedYieldKeywordES6.errors.txt | 4 ++-- tests/baselines/reference/yieldExpression1.errors.txt | 4 ++-- 32 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 60f7dd8588d..9d277bbe549 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -433,8 +433,8 @@ module ts { _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, - yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported.", isEarly: true }, - generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "'generators' are not currently supported.", isEarly: true }, - Computed_property_names_are_not_currently_supported: { code: 9002, category: DiagnosticCategory.Error, key: "Computed property names are not currently supported.", isEarly: true }, + yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." }, + Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." }, + Computed_property_names_are_not_currently_supported: { code: 9002, category: DiagnosticCategory.Error, key: "Computed property names are not currently supported." }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index eb8cf807c97..599009c6c82 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1822,7 +1822,7 @@ "code": 9000, "isEarly": true }, - "'generators' are not currently supported.": { + "Generators are not currently supported.": { "category": "Error", "code": 9001, "isEarly": true diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7f8d766cc93..7ff154a43ed 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5060,7 +5060,7 @@ module ts { function checkForGenerator(node: FunctionLikeDeclaration) { if (node.asteriskToken) { - return grammarErrorOnNode(node.asteriskToken, Diagnostics.generators_are_not_currently_supported); + return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_not_currently_supported); } } diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt index 8c1585c2ec6..8c6b09c82d6 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration10_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ==== function * foo(a = yield => yield) { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt index ae307281b75..1dd8c3f6a1b 100644 --- a/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration11_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts (1 errors) ==== function * yield() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt index 50b6b15d708..a46097e8a1a 100644 --- a/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS9001: Generators are not currently supported. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (2 errors) ==== function * foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. // Legal to use 'yield' in a type context. var v: yield; ~~~~~ diff --git a/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt index b2fdfba350a..71b09983939 100644 --- a/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration1_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts (1 errors) ==== function * foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt index 657a227822d..b5ea3f494a7 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: Generators are not currently supported. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ==== function*foo(a = yield) { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. ~~~~~ !!! error TS2304: Cannot find name 'yield'. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt index f81fd628eb7..71aff1e2488 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: Generators are not currently supported. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (2 errors) ==== function*bar() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. // 'yield' here is an identifier, and not a yield expression. function*foo(a = yield) { ~~~~~ diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt index 7d51bf56ca4..8de32cf0a00 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ==== function * foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. var v = { [yield]: foo } } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionExpression1_es6.errors.txt b/tests/baselines/reference/FunctionExpression1_es6.errors.txt index 10ac3379228..979178fd4b7 100644 --- a/tests/baselines/reference/FunctionExpression1_es6.errors.txt +++ b/tests/baselines/reference/FunctionExpression1_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts (1 errors) ==== var v = function * () { } ~ -!!! error TS9001: 'generators' are not currently supported. \ No newline at end of file +!!! error TS9001: Generators are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionExpression2_es6.errors.txt b/tests/baselines/reference/FunctionExpression2_es6.errors.txt index a95cffcdbeb..ab27947d7c5 100644 --- a/tests/baselines/reference/FunctionExpression2_es6.errors.txt +++ b/tests/baselines/reference/FunctionExpression2_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts (1 errors) ==== var v = function * foo() { } ~ -!!! error TS9001: 'generators' are not currently supported. \ No newline at end of file +!!! error TS9001: Generators are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt index 53b2a016317..bbabbc97463 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments1_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts (1 errors) ==== var v = { *foo() { } } ~ -!!! error TS9001: 'generators' are not currently supported. \ No newline at end of file +!!! error TS9001: Generators are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt index b3415c27f29..393ede66a60 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (1 errors) ==== var v = { *[foo()]() { } } ~ -!!! error TS9001: 'generators' are not currently supported. \ No newline at end of file +!!! error TS9001: Generators are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt index f50934ea705..9d4e312ed22 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration1_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts (1 errors) ==== class C { *foo() { } ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt index 667e0e5e58d..6373c800994 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration2_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts (1 errors) ==== class C { public * foo() { } ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt index b61137f1f3d..b43e266e2a5 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (1 errors) ==== class C { *[foo]() { } ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt index 40afaf5bc65..ea87da50ed3 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration7_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts (1 errors) ==== class C { *foo() { } ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression10_es6.errors.txt b/tests/baselines/reference/YieldExpression10_es6.errors.txt index e2e52a0c5be..41d6bb5bf24 100644 --- a/tests/baselines/reference/YieldExpression10_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression10_es6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (1 errors) ==== var v = { * foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. yield(foo); } } diff --git a/tests/baselines/reference/YieldExpression11_es6.errors.txt b/tests/baselines/reference/YieldExpression11_es6.errors.txt index 534d8b17bf2..eea108619bc 100644 --- a/tests/baselines/reference/YieldExpression11_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression11_es6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (1 errors) ==== class C { *foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. yield(foo); } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression13_es6.errors.txt b/tests/baselines/reference/YieldExpression13_es6.errors.txt index 1d2cd4e3c25..185fb2f6193 100644 --- a/tests/baselines/reference/YieldExpression13_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression13_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (1 errors) ==== function* foo() { yield } ~ -!!! error TS9001: 'generators' are not currently supported. \ No newline at end of file +!!! error TS9001: Generators are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression16_es6.errors.txt b/tests/baselines/reference/YieldExpression16_es6.errors.txt index 1963539d4a8..54536a7d4fe 100644 --- a/tests/baselines/reference/YieldExpression16_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression16_es6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. function bar() { yield foo; } diff --git a/tests/baselines/reference/YieldExpression19_es6.errors.txt b/tests/baselines/reference/YieldExpression19_es6.errors.txt index a427ab18f70..81cf0e2063c 100644 --- a/tests/baselines/reference/YieldExpression19_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression19_es6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (1 errors) ==== function*foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. function bar() { function* quux() { yield(foo); diff --git a/tests/baselines/reference/YieldExpression3_es6.errors.txt b/tests/baselines/reference/YieldExpression3_es6.errors.txt index 9983eefc9a6..91da79fbb53 100644 --- a/tests/baselines/reference/YieldExpression3_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression3_es6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. yield yield } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression4_es6.errors.txt b/tests/baselines/reference/YieldExpression4_es6.errors.txt index 58d1326ba59..ca7ed3d354c 100644 --- a/tests/baselines/reference/YieldExpression4_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression4_es6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. yield; yield; } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression6_es6.errors.txt b/tests/baselines/reference/YieldExpression6_es6.errors.txt index 5ef38d249d5..d8ce78a300f 100644 --- a/tests/baselines/reference/YieldExpression6_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression6_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. yield*foo } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression7_es6.errors.txt b/tests/baselines/reference/YieldExpression7_es6.errors.txt index 11914f6fbb4..87b15ac9f71 100644 --- a/tests/baselines/reference/YieldExpression7_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression7_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. yield foo } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression8_es6.errors.txt b/tests/baselines/reference/YieldExpression8_es6.errors.txt index 591c1fade08..77bd03382aa 100644 --- a/tests/baselines/reference/YieldExpression8_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression8_es6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS9001: Generators are not currently supported. tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error TS2304: Cannot find name 'yield'. @@ -8,6 +8,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error !!! error TS2304: Cannot find name 'yield'. function* foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. yield(foo); } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression9_es6.errors.txt b/tests/baselines/reference/YieldExpression9_es6.errors.txt index 108028d2282..ae1b105903a 100644 --- a/tests/baselines/reference/YieldExpression9_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression9_es6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (1 errors) ==== var v = function*() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. yield(foo); } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt index b12b552d5f0..24d64d8f29e 100644 --- a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt +++ b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts (1 errors) ==== function* gen() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. // Once this is supported, the inner expression does not need to be parenthesized. var x = yield `abc${ x }def`; } diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt index 5270e79679e..20542cb12b7 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,9): error TS9001: Generators are not currently supported. ==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts (1 errors) ==== function* gen() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; } diff --git a/tests/baselines/reference/yieldExpression1.errors.txt b/tests/baselines/reference/yieldExpression1.errors.txt index ecac77698c5..33d9c1bf62e 100644 --- a/tests/baselines/reference/yieldExpression1.errors.txt +++ b/tests/baselines/reference/yieldExpression1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/yieldExpression1.ts(1,9): error TS9001: 'generators' are not currently supported. +tests/cases/compiler/yieldExpression1.ts(1,9): error TS9001: Generators are not currently supported. ==== tests/cases/compiler/yieldExpression1.ts (1 errors) ==== function* foo() { ~ -!!! error TS9001: 'generators' are not currently supported. +!!! error TS9001: Generators are not currently supported. yield } \ No newline at end of file From 00449d80a3868bfee70bcea8807a899119a1ee7b Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 12:47:19 -0800 Subject: [PATCH 28/74] Merge disallow computed property grammar error; there are still errors from generator and the fact that other grammar check haven't moved yet --- src/compiler/checker.ts | 16 ++++++++++++++++ .../diagnosticInformationMap.generated.ts | 6 +++--- src/compiler/diagnosticMessages.json | 1 + .../reference/computedPropertyNames2.errors.txt | 12 ++++++------ .../reference/computedPropertyNames3.errors.txt | 12 ++++++------ 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 91f806e0518..154293870fa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7155,6 +7155,11 @@ module ts { } function checkMethodDeclaration(node: MethodDeclaration) { + // Grammar checking + if (node.name.kind === SyntaxKind.ComputedPropertyName) { + checkGrammarComputedPropertyName(node.name); + } + checkFunctionLikeDeclaration(node); } @@ -7242,6 +7247,11 @@ module ts { } function checkAccessorDeclaration(node: AccessorDeclaration) { + // Grammar checking + if (node.name.kind === SyntaxKind.ComputedPropertyName) { + checkGrammarComputedPropertyName(node.name); + } + if (fullTypeCheck) { if (node.kind === SyntaxKind.GetAccessor) { if (!isInAmbientContext(node) && node.body && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { @@ -10000,12 +10010,18 @@ module ts { } function checkGrammarComputedPropertyName(node: ComputedPropertyName): void { + // Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4 + // Once full support is added, remove this error. + grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_not_currently_supported); + + /* TODO (jfreeman) if (compilerOptions.target < ScriptTarget.ES6) { grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); } else if (node.expression.kind === SyntaxKind.BinaryExpression && (node.expression).operator === SyntaxKind.CommaToken) { grammarErrorOnNode(node.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } + */ } function hasParseDiagnostics(sourceFile: SourceFile): boolean { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 9d277bbe549..f955683dbff 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -433,8 +433,8 @@ module ts { _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, - yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." }, - Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." }, - Computed_property_names_are_not_currently_supported: { code: 9002, category: DiagnosticCategory.Error, key: "Computed property names are not currently supported." }, + yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported.", isEarly: true }, + Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported.", isEarly: true }, + Computed_property_names_are_not_currently_supported: { code: 9002, category: DiagnosticCategory.Error, key: "Computed property names are not currently supported.", isEarly: true }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 599009c6c82..261fc77db36 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1830,5 +1830,6 @@ "Computed property names are not currently supported.": { "category": "Error", "code": 9002, + "isEarly": true } } diff --git a/tests/baselines/reference/computedPropertyNames2.errors.txt b/tests/baselines/reference/computedPropertyNames2.errors.txt index e7cc84a8f6e..3dd4ac01d5f 100644 --- a/tests/baselines/reference/computedPropertyNames2.errors.txt +++ b/tests/baselines/reference/computedPropertyNames2.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(4,5): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(5,12): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(7,9): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(9,16): error TS9002: Computed property names are not currently supported. -tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(6,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. -tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts (8 errors) ==== @@ -20,17 +20,17 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames2.ts(8,16): !!! error TS9002: Computed property names are not currently supported. get [accessorName]() { } ~~~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. - ~~~~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + ~~~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. set [accessorName](v) { } ~~~~~~~~~~~~~~ !!! error TS9002: Computed property names are not currently supported. static get [accessorName]() { } ~~~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. - ~~~~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + ~~~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. static set [accessorName](v) { } ~~~~~~~~~~~~~~ !!! error TS9002: Computed property names are not currently supported. diff --git a/tests/baselines/reference/computedPropertyNames3.errors.txt b/tests/baselines/reference/computedPropertyNames3.errors.txt index a1d6e09421b..084a1f8889f 100644 --- a/tests/baselines/reference/computedPropertyNames3.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(3,5): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(4,12): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(6,9): error TS9002: Computed property names are not currently supported. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(8,16): error TS9002: Computed property names are not currently supported. -tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. -tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts (8 errors) ==== @@ -19,17 +19,17 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3.ts(7,16): !!! error TS9002: Computed property names are not currently supported. get [delete id]() { } ~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. - ~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + ~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. set [[0, 1]](v) { } ~~~~~~~~ !!! error TS9002: Computed property names are not currently supported. static get [""]() { } ~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. - ~~~~~~~~~~~~ !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + ~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. static set [id.toString()](v) { } ~~~~~~~~~~~~~~~ !!! error TS9002: Computed property names are not currently supported. From 90e1d4244f5a3084411f2828e000b07d51a00e9f Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 12:59:00 -0800 Subject: [PATCH 29/74] Move grammar check: deleteExpression --- src/compiler/checker.ts | 7 +++++++ src/compiler/parser.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 154293870fa..a451fcfb80a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6555,6 +6555,13 @@ module ts { } function checkDeleteExpression(node: DeleteExpression): Type { + // Grammar checking + if (node.parserContextFlags & ParserContextFlags.StrictMode && node.expression.kind === SyntaxKind.Identifier) { + // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its + // UnaryExpression is a direct reference to a variable, function argument, or function name + grammarErrorOnNode(node.expression, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); + } + var operandType = checkExpression(node.expression); return booleanType; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7ff154a43ed..6e393fcc8fc 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4640,7 +4640,7 @@ module ts { //case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); //case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); case SyntaxKind.Constructor: return checkConstructor(node); - case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); + //case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); case SyntaxKind.ExportAssignment: return checkExportAssignment(node); case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); From afc04c8db88dc2692067aecebee3bbb04aa7d054 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 13:16:19 -0800 Subject: [PATCH 30/74] Move type checking: elementAccessExpression; there are still errors from not moving other grammar checking into type checker --- src/compiler/checker.ts | 15 ++++++++++++ src/compiler/parser.ts | 2 +- .../reference/badArrayIndex.errors.txt | 8 +++---- ...annotInvokeNewOnErrorExpression.errors.txt | 8 +++---- .../reference/createArray.errors.txt | 18 +++++++------- .../baselines/reference/libMembers.errors.txt | 2 +- ...rserObjectCreationArrayLiteral1.errors.txt | 8 +++---- ...rserObjectCreationArrayLiteral3.errors.txt | 8 +++---- .../reference/parserRealSource10.errors.txt | 24 +++++++++---------- .../reference/parserRealSource11.errors.txt | 6 ++--- .../reference/parserRealSource7.errors.txt | 6 ++--- .../reference/parserRealSource9.errors.txt | 6 ++--- 12 files changed, 63 insertions(+), 48 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a451fcfb80a..490b1ae9182 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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 && (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; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6e393fcc8fc..a26d928bf1c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4641,7 +4641,7 @@ module ts { //case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); case SyntaxKind.Constructor: return checkConstructor(node); //case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); - case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); + //case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); case SyntaxKind.ExportAssignment: return checkExportAssignment(node); case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); case SyntaxKind.ForInStatement: return checkForInStatement(node); diff --git a/tests/baselines/reference/badArrayIndex.errors.txt b/tests/baselines/reference/badArrayIndex.errors.txt index 818870f6c26..4830ff1f693 100644 --- a/tests/baselines/reference/badArrayIndex.errors.txt +++ b/tests/baselines/reference/badArrayIndex.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/badArrayIndex.ts(1,22): error TS1109: Expression expected. tests/cases/compiler/badArrayIndex.ts(1,15): error TS2304: Cannot find name 'number'. +tests/cases/compiler/badArrayIndex.ts(1,22): error TS1109: Expression expected. ==== tests/cases/compiler/badArrayIndex.ts (2 errors) ==== var results = number[]; - ~ -!!! error TS1109: Expression expected. ~~~~~~ -!!! error TS2304: Cannot find name 'number'. \ No newline at end of file +!!! error TS2304: Cannot find name 'number'. + ~ +!!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/cannotInvokeNewOnErrorExpression.errors.txt b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.errors.txt index cfb9287cdbc..fab981a8571 100644 --- a/tests/baselines/reference/cannotInvokeNewOnErrorExpression.errors.txt +++ b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts(5,21): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts(5,15): error TS2339: Property 'ClassA' does not exist on type 'typeof M'. +tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts(5,21): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ==== tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts (2 errors) ==== @@ -8,7 +8,7 @@ tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts(5,15): error TS2339: Pr class ClassA {} } var t = new M.ClassA[]; - ~~ -!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~ -!!! error TS2339: Property 'ClassA' does not exist on type 'typeof M'. \ No newline at end of file +!!! error TS2339: Property 'ClassA' does not exist on type 'typeof M'. + ~~ +!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. \ No newline at end of file diff --git a/tests/baselines/reference/createArray.errors.txt b/tests/baselines/reference/createArray.errors.txt index 6f79c4b47d2..31f6b880030 100644 --- a/tests/baselines/reference/createArray.errors.txt +++ b/tests/baselines/reference/createArray.errors.txt @@ -1,18 +1,18 @@ +tests/cases/compiler/createArray.ts(1,12): error TS2304: Cannot find name 'number'. tests/cases/compiler/createArray.ts(1,18): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/createArray.ts(6,6): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/createArray.ts(7,19): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/createArray.ts(8,18): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/compiler/createArray.ts(1,12): error TS2304: Cannot find name 'number'. tests/cases/compiler/createArray.ts(7,12): error TS2304: Cannot find name 'boolean'. +tests/cases/compiler/createArray.ts(7,19): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/createArray.ts(8,12): error TS2304: Cannot find name 'string'. +tests/cases/compiler/createArray.ts(8,18): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ==== tests/cases/compiler/createArray.ts (7 errors) ==== var na=new number[]; - ~~ -!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~ !!! error TS2304: Cannot find name 'number'. + ~~ +!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. class C { } @@ -21,15 +21,15 @@ tests/cases/compiler/createArray.ts(8,12): error TS2304: Cannot find name 'strin ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. var ba=new boolean[]; - ~~ -!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~~ !!! error TS2304: Cannot find name 'boolean'. - var sa=new string[]; - ~~ + ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. + var sa=new string[]; ~~~~~~ !!! error TS2304: Cannot find name 'string'. + ~~ +!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. function f(s:string):number { return 0; } if (ba[14]) { diff --git a/tests/baselines/reference/libMembers.errors.txt b/tests/baselines/reference/libMembers.errors.txt index a6af67821b3..4b025b9a95b 100644 --- a/tests/baselines/reference/libMembers.errors.txt +++ b/tests/baselines/reference/libMembers.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/libMembers.ts(9,16): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/libMembers.ts(4,3): error TS2339: Property 'subby' does not exist on type 'string'. +tests/cases/compiler/libMembers.ts(9,16): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/libMembers.ts(12,15): error TS2339: Property 'prototype' does not exist on type 'C'. diff --git a/tests/baselines/reference/parserObjectCreationArrayLiteral1.errors.txt b/tests/baselines/reference/parserObjectCreationArrayLiteral1.errors.txt index 04be3a6d041..051d2357635 100644 --- a/tests/baselines/reference/parserObjectCreationArrayLiteral1.errors.txt +++ b/tests/baselines/reference/parserObjectCreationArrayLiteral1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral1.ts(1,8): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral1.ts(1,5): error TS2304: Cannot find name 'Foo'. +tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral1.ts(1,8): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ==== tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral1.ts (2 errors) ==== new Foo[]; - ~~ -!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~ -!!! error TS2304: Cannot find name 'Foo'. \ No newline at end of file +!!! error TS2304: Cannot find name 'Foo'. + ~~ +!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. \ No newline at end of file diff --git a/tests/baselines/reference/parserObjectCreationArrayLiteral3.errors.txt b/tests/baselines/reference/parserObjectCreationArrayLiteral3.errors.txt index 89f861cfcdb..b7d18f471da 100644 --- a/tests/baselines/reference/parserObjectCreationArrayLiteral3.errors.txt +++ b/tests/baselines/reference/parserObjectCreationArrayLiteral3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral3.ts(1,8): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral3.ts(1,5): error TS2304: Cannot find name 'Foo'. +tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral3.ts(1,8): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ==== tests/cases/conformance/parser/ecmascript5/parserObjectCreationArrayLiteral3.ts (2 errors) ==== new Foo[](); - ~~ -!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~ -!!! error TS2304: Cannot find name 'Foo'. \ No newline at end of file +!!! error TS2304: Cannot find name 'Foo'. + ~~ +!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. \ No newline at end of file diff --git a/tests/baselines/reference/parserRealSource10.errors.txt b/tests/baselines/reference/parserRealSource10.errors.txt index aabafd751e7..b3c40202c4f 100644 --- a/tests/baselines/reference/parserRealSource10.errors.txt +++ b/tests/baselines/reference/parserRealSource10.errors.txt @@ -1,12 +1,11 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(127,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(128,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(129,47): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(130,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(449,40): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(128,36): error TS2304: Cannot find name 'string'. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(128,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(129,41): error TS2304: Cannot find name 'number'. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(129,47): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(130,35): error TS2304: Cannot find name 'boolean'. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(130,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(179,54): error TS2304: Cannot find name 'ErrorRecoverySet'. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(184,28): error TS2304: Cannot find name 'ErrorRecoverySet'. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(188,34): error TS2304: Cannot find name 'NodeType'. @@ -340,6 +339,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(312,128): error tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(312,149): error TS2304: Cannot find name 'ErrorRecoverySet'. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(355,52): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(356,53): error TS2304: Cannot find name 'NodeType'. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(449,40): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ==== tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts (342 errors) ==== @@ -475,20 +475,20 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(356,53): error ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. export var nodeTypeTable = new string[]; - ~~ -!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~ !!! error TS2304: Cannot find name 'string'. - export var nodeTypeToTokTable = new number[]; - ~~ -!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. - ~~~~~~ -!!! error TS2304: Cannot find name 'number'. - export var noRegexTable = new boolean[]; ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. + export var nodeTypeToTokTable = new number[]; + ~~~~~~ +!!! error TS2304: Cannot find name 'number'. + ~~ +!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. + export var noRegexTable = new boolean[]; ~~~~~~~ !!! error TS2304: Cannot find name 'boolean'. + ~~ +!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. noRegexTable[TokenID.Identifier] = true; noRegexTable[TokenID.StringLiteral] = true; diff --git a/tests/baselines/reference/parserRealSource11.errors.txt b/tests/baselines/reference/parserRealSource11.errors.txt index 966da980097..dc314c8d3e2 100644 --- a/tests/baselines/reference/parserRealSource11.errors.txt +++ b/tests/baselines/reference/parserRealSource11.errors.txt @@ -1,8 +1,5 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(193,40): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(867,29): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1009,45): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1024,47): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(13,22): error TS2304: Cannot find name 'Type'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(14,24): error TS2304: Cannot find name 'ASTFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(17,38): error TS2304: Cannot find name 'CompilerDiagnostics'. @@ -44,6 +41,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(151,57): error tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(155,26): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(184,19): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(192,32): error TS2304: Cannot find name 'SymbolScope'. +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(193,40): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(196,19): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(199,42): error TS2304: Cannot find name 'ControlFlowContext'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(219,33): error TS2304: Cannot find name 'NodeType'. @@ -252,7 +250,9 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1004,44): error tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1004,67): error TS2304: Cannot find name 'FncFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1005,57): error TS2304: Cannot find name 'FncFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1007,47): error TS2304: Cannot find name 'Symbol'. +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1009,45): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1022,32): error TS2304: Cannot find name 'Symbol'. +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1024,47): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1032,36): error TS2304: Cannot find name 'ControlFlowContext'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1033,29): error TS2304: Cannot find name 'BasicBlock'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1034,28): error TS2304: Cannot find name 'BasicBlock'. diff --git a/tests/baselines/reference/parserRealSource7.errors.txt b/tests/baselines/reference/parserRealSource7.errors.txt index 7fddac2c467..7945e5d7034 100644 --- a/tests/baselines/reference/parserRealSource7.errors.txt +++ b/tests/baselines/reference/parserRealSource7.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. -tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(16,45): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(12,38): error TS2304: Cannot find name 'ASTList'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(12,62): error TS2304: Cannot find name 'TypeLink'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(16,37): error TS2304: Cannot find name 'TypeLink'. +tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(16,45): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(21,36): error TS2304: Cannot find name 'TypeLink'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(29,29): error TS2304: Cannot find name 'Type'. tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(29,45): error TS2304: Cannot find name 'TypeDeclaration'. @@ -326,10 +326,10 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource7.ts(828,13): error T var len = bases.members.length; if (baseTypeLinks == null) { baseTypeLinks = new TypeLink[]; - ~~ -!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~~~~~ !!! error TS2304: Cannot find name 'TypeLink'. + ~~ +!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. } for (var i = 0; i < len; i++) { var baseExpr = bases.members[i]; diff --git a/tests/baselines/reference/parserRealSource9.errors.txt b/tests/baselines/reference/parserRealSource9.errors.txt index 1880a72f189..9d89848ff20 100644 --- a/tests/baselines/reference/parserRealSource9.errors.txt +++ b/tests/baselines/reference/parserRealSource9.errors.txt @@ -1,10 +1,10 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. -tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(12,39): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(8,38): error TS2304: Cannot find name 'TypeChecker'. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(9,48): error TS2304: Cannot find name 'TypeLink'. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(9,67): error TS2304: Cannot find name 'SymbolScope'. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(10,30): error TS2304: Cannot find name 'Type'. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(12,35): error TS2304: Cannot find name 'Type'. +tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(12,39): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(29,36): error TS2304: Cannot find name 'SymbolScope'. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(29,55): error TS2304: Cannot find name 'Type'. tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(67,54): error TS2304: Cannot find name 'SignatureGroup'. @@ -56,10 +56,10 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource9.ts(200,48): error T !!! error TS2304: Cannot find name 'Type'. if (typeLinks) { extendsList = new Type[]; - ~~ -!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. ~~~~ !!! error TS2304: Cannot find name 'Type'. + ~~ +!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. for (var i = 0, len = typeLinks.length; i < len; i++) { var typeLink = typeLinks[i]; this.checker.resolvingBases = true; From 49bc20a05ff1005f46489685a5664427047e745c Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 13:32:01 -0800 Subject: [PATCH 31/74] Move grammar checking: exportAssignment; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 5 +++++ src/compiler/parser.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 490b1ae9182..6f81b879885 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8861,6 +8861,11 @@ module ts { } function checkExportAssignment(node: ExportAssignment) { + // Grammar checking + if (node.flags & NodeFlags.Modifier) { + grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers); + } + var container = node.parent; if (container.kind !== SyntaxKind.SourceFile) { // In a module, the immediate parent will be a block, so climb up one more parent diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a26d928bf1c..2aacbe5ab04 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4642,7 +4642,7 @@ module ts { case SyntaxKind.Constructor: return checkConstructor(node); //case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); //case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); - case SyntaxKind.ExportAssignment: return checkExportAssignment(node); + //case SyntaxKind.ExportAssignment: return checkExportAssignment(node); case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); case SyntaxKind.ForInStatement: return checkForInStatement(node); case SyntaxKind.ForStatement: return checkForStatement(node); From ae4b5dc842fa042485c2e275170d4ff6e714357c Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 14:02:32 -0800 Subject: [PATCH 32/74] Move grammar checking: externalModuleReferences; there are still errors from incomplete grammar checking migration --- src/compiler/checker.ts | 10 ++++++++-- src/compiler/parser.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6f81b879885..e3123a54c51 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -468,6 +468,13 @@ module ts { if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfKind(symbol, SyntaxKind.ImportDeclaration); + // Grammar checking + if (node.moduleReference.kind === SyntaxKind.ExternalModuleReference) { + if ((node.moduleReference).expression.kind !== SyntaxKind.StringLiteral) { + grammarErrorOnNode((node.moduleReference).expression, Diagnostics.String_literal_expected); + } + } + var target = node.moduleReference.kind === SyntaxKind.ExternalModuleReference ? resolveExternalModuleName(node, getExternalModuleImportDeclarationExpression(node)) : getSymbolOfPartOfRightHandSideOfImport(node.moduleReference, node); @@ -10040,15 +10047,14 @@ module ts { // Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4 // Once full support is added, remove this error. grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_not_currently_supported); + return; - /* TODO (jfreeman) if (compilerOptions.target < ScriptTarget.ES6) { grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); } else if (node.expression.kind === SyntaxKind.BinaryExpression && (node.expression).operator === SyntaxKind.CommaToken) { grammarErrorOnNode(node.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } - */ } function hasParseDiagnostics(sourceFile: SourceFile): boolean { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 2aacbe5ab04..ed30af4301b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4643,7 +4643,7 @@ module ts { //case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); //case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); //case SyntaxKind.ExportAssignment: return checkExportAssignment(node); - case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); + //case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); case SyntaxKind.ForInStatement: return checkForInStatement(node); case SyntaxKind.ForStatement: return checkForStatement(node); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); From 56cf566f892e92a18b35f788783674e2e47b21f6 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 15:10:01 -0800 Subject: [PATCH 33/74] Move grammar checking: functionExpression --- src/compiler/checker.ts | 23 +++++++++++++++---- src/compiler/parser.ts | 2 +- ...eterWithoutAnnotationIsAnyArray.errors.txt | 2 +- .../restParametersOfNonArrayTypes.errors.txt | 2 +- .../restParametersOfNonArrayTypes2.errors.txt | 4 ++-- ...ametersWithArrayTypeAnnotations.errors.txt | 4 ++-- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e3123a54c51..a0fde165f66 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6432,8 +6432,9 @@ module ts { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); // Grammar checking - if (node.kind === SyntaxKind.ArrowFunction) { - checkGrammarFunctionLikeDeclaration(node); + var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); + if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) { + checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -9955,9 +9956,9 @@ module ts { } } - function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration) { + function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { // Prevent cascading error by short-circuit - checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters); + return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters); } function checkGrammarIndexSignatureParameters(node: SignatureDeclaration): boolean { @@ -10057,6 +10058,20 @@ module ts { } } + function checkGrammarForGenerator(node: FunctionLikeDeclaration) { + if (node.asteriskToken) { + return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_not_currently_supported); + } + } + + function checkGrammarFunctionName(name: Node) { + if (name && name.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(name)) { + // It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the + // Identifier of a FunctionLikeDeclaration or FunctionExpression or as a formal parameter name(13.1) + return reportGrammarErrorOfInvalidUseInStrictMode(name); + } + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ed30af4301b..c67d0e90ae4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4647,7 +4647,7 @@ module ts { case SyntaxKind.ForInStatement: return checkForInStatement(node); case SyntaxKind.ForStatement: return checkForStatement(node); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); - case SyntaxKind.FunctionExpression: return checkFunctionExpression(node); + //case SyntaxKind.FunctionExpression: return checkFunctionExpression(node); case SyntaxKind.GetAccessor: return checkGetAccessor(node); case SyntaxKind.HeritageClause: return checkHeritageClause(node); case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node); diff --git a/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt b/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt index 6685d5fe69f..72614738ed9 100644 --- a/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt +++ b/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. ==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts (3 errors) ==== diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt b/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt index df16e72ea79..6c3c8f5fe19 100644 --- a/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt +++ b/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt @@ -1,5 +1,4 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(3,14): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(4,22): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. @@ -12,6 +11,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfN tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(17,6): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(18,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(22,9): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(23,21): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(23,35): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(24,9): error TS2370: A rest parameter must be of an array type. diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt b/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt index b70c7fb467d..aeae6846dcc 100644 --- a/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt +++ b/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt @@ -1,7 +1,5 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(17,9): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(27,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(44,9): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(54,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(7,14): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(8,22): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,11): error TS1014: A rest parameter must be last in a parameter list. @@ -14,6 +12,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfN tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(21,6): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(22,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(26,9): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(27,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(27,21): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(27,36): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(28,9): error TS2370: A rest parameter must be of an array type. @@ -29,6 +28,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfN tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(48,6): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(49,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(53,9): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(54,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(54,21): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(54,45): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(55,9): error TS2370: A rest parameter must be of an array type. diff --git a/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt b/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt index 05075fc6175..bd813e8fc55 100644 --- a/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt +++ b/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(40,9): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(50,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(32,11): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(50,21): error TS1014: A rest parameter must be last in a parameter list. ==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts (6 errors) ==== From 5b98eba3d8e2f7ef0119b14088e6460300e8eaee Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 15:10:35 -0800 Subject: [PATCH 34/74] Address code review; check class heritage clause into its own function --- src/compiler/checker.ts | 78 ++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a0fde165f66..97c39dd8aaf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8263,43 +8263,7 @@ module ts { function checkClassDeclaration(node: ClassDeclaration) { // Grammar checking - var seenExtendsClause = false; - var seenImplementsClause = false; - - if (!checkGrammarModifiers(node) && node.heritageClauses) { - for (var i = 0, n = node.heritageClauses.length; i < n; i++) { - Debug.assert(i <= 2); - var heritageClause = node.heritageClauses[i]; - - if (heritageClause.token === SyntaxKind.ExtendsKeyword) { - if (seenExtendsClause) { - grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen) - break; - } - - if (seenImplementsClause) { - grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_must_precede_implements_clause); - break; - } - - if (heritageClause.types.length > 1) { - grammarErrorOnFirstToken(heritageClause.types[1], Diagnostics.Classes_can_only_extend_a_single_class); - break; - } - - seenExtendsClause = true; - } - else { - Debug.assert(heritageClause.token === SyntaxKind.ImplementsKeyword); - if (seenImplementsClause) { - grammarErrorOnFirstToken(heritageClause, Diagnostics.implements_clause_already_seen); - break; - } - - seenImplementsClause = true; - } - } - } + checkGrammarClassDeclarationHeritageClauses(node); checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0); checkTypeParameters(node.typeParameters); @@ -10044,6 +10008,46 @@ module ts { } } + function checkGrammarClassDeclarationHeritageClauses(node: ClassDeclaration) { + var seenExtendsClause = false; + var seenImplementsClause = false; + + if (!checkGrammarModifiers(node) && node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + Debug.assert(i <= 2); + var heritageClause = node.heritageClauses[i]; + + if (heritageClause.token === SyntaxKind.ExtendsKeyword) { + if (seenExtendsClause) { + grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen) + break; + } + + if (seenImplementsClause) { + grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_must_precede_implements_clause); + break; + } + + if (heritageClause.types.length > 1) { + grammarErrorOnFirstToken(heritageClause.types[1], Diagnostics.Classes_can_only_extend_a_single_class); + break; + } + + seenExtendsClause = true; + } + else { + Debug.assert(heritageClause.token === SyntaxKind.ImplementsKeyword); + if (seenImplementsClause) { + grammarErrorOnFirstToken(heritageClause, Diagnostics.implements_clause_already_seen); + break; + } + + seenImplementsClause = true; + } + } + } + } + function checkGrammarComputedPropertyName(node: ComputedPropertyName): void { // Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4 // Once full support is added, remove this error. From 3903a650623a5420132a2a3db01b552a3c504dc8 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 15:52:27 -0800 Subject: [PATCH 35/74] Move grammar check: InterfaceDeclaration, HeritageClause --- src/compiler/checker.ts | 46 +++++++++++++++++++ src/compiler/parser.ts | 4 +- ...interfaceThatInheritsFromItself.errors.txt | 2 +- ...very_ExtendsOrImplementsClause2.errors.txt | 6 +-- ...very_ExtendsOrImplementsClause4.errors.txt | 6 +-- ...very_ExtendsOrImplementsClause5.errors.txt | 12 ++--- .../parserInterfaceDeclaration1.errors.txt | 6 +-- 7 files changed, 64 insertions(+), 18 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 97c39dd8aaf..8c4cfeec5fa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8468,6 +8468,9 @@ module ts { } function checkInterfaceDeclaration(node: InterfaceDeclaration) { + // Grammar checking + checkGrammarInterfaceDeclaration(node); + checkTypeParameters(node.typeParameters); if (fullTypeCheck) { checkTypeNameIsReserved(node.name, Diagnostics.Interface_name_cannot_be_0); @@ -10008,6 +10011,18 @@ module ts { } } + function checkGrammarHeritageClause(node: HeritageClause): boolean { + var types = node.types; + if (checkGrammarForDisallowedTrailingComma(types)) { + return true; + } + var listType = tokenToString(node.token); + if (types && types.length === 0) { + var sourceFile = getSourceFileOfNode(node); + return grammarErrorAtPos(sourceFile, types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType) + } + } + function checkGrammarClassDeclarationHeritageClauses(node: ClassDeclaration) { var seenExtendsClause = false; var seenImplementsClause = false; @@ -10044,10 +10059,41 @@ module ts { seenImplementsClause = true; } + + // Grammar checking heritageClause inside class declaration + checkGrammarHeritageClause(heritageClause); } } } + function checkGrammarInterfaceDeclaration(node: InterfaceDeclaration) { + var seenExtendsClause = false; + + if (node.heritageClauses) { + for (var i = 0, n = node.heritageClauses.length; i < n; i++) { + Debug.assert(i <= 1); + var heritageClause = node.heritageClauses[i]; + + if (heritageClause.token === SyntaxKind.ExtendsKeyword) { + if (seenExtendsClause) { + return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen); + } + + seenExtendsClause = true; + } + else { + Debug.assert(heritageClause.token === SyntaxKind.ImplementsKeyword); + return grammarErrorOnFirstToken(heritageClause, Diagnostics.Interface_declaration_cannot_have_implements_clause); + } + + // Grammar checking heritageClause inside class declaration + checkGrammarHeritageClause(heritageClause); + } + } + + return false; + } + function checkGrammarComputedPropertyName(node: ComputedPropertyName): void { // Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4 // Once full support is added, remove this error. diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c67d0e90ae4..7fb859f750a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4649,8 +4649,8 @@ module ts { case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); //case SyntaxKind.FunctionExpression: return checkFunctionExpression(node); case SyntaxKind.GetAccessor: return checkGetAccessor(node); - case SyntaxKind.HeritageClause: return checkHeritageClause(node); - case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node); + //case SyntaxKind.HeritageClause: return checkHeritageClause(node); + //case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node); case SyntaxKind.LabeledStatement: return checkLabeledStatement(node); case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(node); case SyntaxKind.MethodDeclaration: diff --git a/tests/baselines/reference/interfaceThatInheritsFromItself.errors.txt b/tests/baselines/reference/interfaceThatInheritsFromItself.errors.txt index 440650717bd..b1e47347117 100644 --- a/tests/baselines/reference/interfaceThatInheritsFromItself.errors.txt +++ b/tests/baselines/reference/interfaceThatInheritsFromItself.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(10,15): error TS1176: Interface declaration cannot have 'implements' clause. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(1,11): error TS2310: Type 'Foo' recursively references itself as a base type. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(4,11): error TS2310: Type 'Foo2' recursively references itself as a base type. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(7,11): error TS2310: Type 'Foo3' recursively references itself as a base type. +tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts(10,15): error TS1176: Interface declaration cannot have 'implements' clause. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceThatInheritsFromItself.ts (4 errors) ==== diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.errors.txt b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.errors.txt index 9e4d8b76d75..c3aee20c780 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause2.ts(1,18): error TS1009: Trailing comma not allowed. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause2.ts(1,17): error TS2304: Cannot find name 'A'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause2.ts(1,18): error TS1009: Trailing comma not allowed. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause2.ts (2 errors) ==== class C extends A, { - ~ -!!! error TS1009: Trailing comma not allowed. ~ !!! error TS2304: Cannot find name 'A'. + ~ +!!! error TS1009: Trailing comma not allowed. } \ No newline at end of file diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.errors.txt b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.errors.txt index 6d637831c45..aaf5b803267 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause4.ts(1,29): error TS1097: 'implements' list cannot be empty. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause4.ts(1,17): error TS2304: Cannot find name 'A'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause4.ts(1,29): error TS1097: 'implements' list cannot be empty. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause4.ts (2 errors) ==== class C extends A implements { - -!!! error TS1097: 'implements' list cannot be empty. ~ !!! error TS2304: Cannot find name 'A'. + +!!! error TS1097: 'implements' list cannot be empty. } \ No newline at end of file diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.errors.txt b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.errors.txt index 7ffab4742f3..e1ab30fe5f1 100644 --- a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.errors.txt @@ -1,17 +1,17 @@ -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,18): error TS1009: Trailing comma not allowed. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,32): error TS1009: Trailing comma not allowed. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,17): error TS2304: Cannot find name 'A'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,18): error TS1009: Trailing comma not allowed. tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,31): error TS2304: Cannot find name 'B'. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts(1,32): error TS1009: Trailing comma not allowed. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ExtendsOrImplementsClauses/parserErrorRecovery_ExtendsOrImplementsClause5.ts (4 errors) ==== class C extends A, implements B, { - ~ -!!! error TS1009: Trailing comma not allowed. - ~ -!!! error TS1009: Trailing comma not allowed. ~ !!! error TS2304: Cannot find name 'A'. + ~ +!!! error TS1009: Trailing comma not allowed. ~ !!! error TS2304: Cannot find name 'B'. + ~ +!!! error TS1009: Trailing comma not allowed. } \ No newline at end of file diff --git a/tests/baselines/reference/parserInterfaceDeclaration1.errors.txt b/tests/baselines/reference/parserInterfaceDeclaration1.errors.txt index 8c8f317b11a..a85b21e6db6 100644 --- a/tests/baselines/reference/parserInterfaceDeclaration1.errors.txt +++ b/tests/baselines/reference/parserInterfaceDeclaration1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts(1,23): error TS1172: 'extends' clause already seen. tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts(1,21): error TS2304: Cannot find name 'A'. +tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts(1,23): error TS1172: 'extends' clause already seen. ==== tests/cases/conformance/parser/ecmascript5/InterfaceDeclarations/parserInterfaceDeclaration1.ts (2 errors) ==== interface I extends A extends B { - ~~~~~~~ -!!! error TS1172: 'extends' clause already seen. ~ !!! error TS2304: Cannot find name 'A'. + ~~~~~~~ +!!! error TS1172: 'extends' clause already seen. } \ No newline at end of file From ee1f19efca361230dc08ceaf6ecbe0adebfbbec2 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 16:27:43 -0800 Subject: [PATCH 36/74] Move grammar checking: labelStatement --- src/compiler/checker.ts | 15 +++++++++++++++ src/compiler/parser.ts | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c4cfeec5fa..da5df9f2efe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8131,6 +8131,21 @@ module ts { } function checkLabeledStatement(node: LabeledStatement) { + // ensure that label is unique + // Grammar checking + var current = node.parent; + while (current) { + if (isAnyFunction(current)) { + break; + } + if (current.kind === SyntaxKind.LabeledStatement && (current).label.text === node.label.text) { + var sourceFile = getSourceFileOfNode(node); + grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceFile.text, node.label)); + break; + } + current = current.parent; + } + checkSourceElement(node.statement); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7fb859f750a..ebd8cc88505 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4651,7 +4651,7 @@ module ts { case SyntaxKind.GetAccessor: return checkGetAccessor(node); //case SyntaxKind.HeritageClause: return checkHeritageClause(node); //case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node); - case SyntaxKind.LabeledStatement: return checkLabeledStatement(node); + //case SyntaxKind.LabeledStatement: return checkLabeledStatement(node); case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(node); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: From c5b9c07542374e472e9854d9149611054ab9f05e Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 17:00:35 -0800 Subject: [PATCH 37/74] Move grammar checking: propertyAssignment; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 9 +++++++++ src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 ++- src/compiler/parser.ts | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index da5df9f2efe..7b99f32e839 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5378,6 +5378,9 @@ module ts { if (member.flags & SymbolFlags.Property || isObjectLiteralMethod(member.declarations[0])) { var memberDecl = member.declarations[0]; if (memberDecl.kind === SyntaxKind.PropertyAssignment) { + // Grammar checking + checkGrammarForInvalidQuestionMark(memberDecl,(memberDecl).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); + var type = checkExpression((memberDecl).initializer, contextualMapper); } else if (memberDecl.kind === SyntaxKind.MethodDeclaration) { @@ -10137,6 +10140,12 @@ module ts { } } + function checkGrammarForInvalidQuestionMark(node: Declaration, questionToken: Node, message: DiagnosticMessage): boolean { + if (questionToken) { + return grammarErrorOnNode(questionToken, message); + } + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index f955683dbff..c9bf3883200 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -122,7 +122,7 @@ module ts { Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, + An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional.", isEarly: true }, yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration.", isEarly: true }, Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums.", isEarly: true }, Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in an ambient context.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 261fc77db36..240661277ee 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -551,7 +551,8 @@ }, "An object member cannot be declared optional.": { "category": "Error", - "code": 1162 + "code": 1162, + "isEarly": true }, "'yield' expression must be contained_within a generator declaration." : { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ebd8cc88505..1674af935ca 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4652,7 +4652,7 @@ module ts { //case SyntaxKind.HeritageClause: return checkHeritageClause(node); //case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node); //case SyntaxKind.LabeledStatement: return checkLabeledStatement(node); - case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(node); + //case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(node); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: return checkMethod(node); From 2cf51e4639af6722dbb8e41525c97a6fef5c4dde Mon Sep 17 00:00:00 2001 From: Yui T Date: Sat, 13 Dec 2014 13:55:16 -0800 Subject: [PATCH 38/74] Move grammar checking: objectLiteralExpression; there are still error from incomplete grammar migration --- src/compiler/checker.ts | 81 +++++++++++++++++-- src/compiler/parser.ts | 2 +- .../duplicateObjectLiteralProperty.errors.txt | 2 +- ...duplicatePropertiesInStrictMode.errors.txt | 2 +- .../twoAccessorsWithSameName.errors.txt | 2 +- 5 files changed, 78 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7b99f32e839..513e47e0747 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5360,18 +5360,14 @@ module ts { } function checkObjectLiteral(node: ObjectLiteralExpression, contextualMapper?: TypeMapper): Type { + // Grammar checking + checkGrammarObjectLiteralExpression(node); + var members = node.symbol.members; var properties: SymbolTable = {}; var contextualType = getContextualType(node); var typeFlags: TypeFlags; - // Grammar checking for computedPropertyName - forEach(node.properties, property => { - if (property.name.kind === SyntaxKind.ComputedPropertyName) { - checkGrammarComputedPropertyName(property.name); - } - }); - for (var id in members) { if (hasProperty(members, id)) { var member = members[id]; @@ -10146,6 +10142,77 @@ module ts { } } + function checkGrammarObjectLiteralExpression(node: ObjectLiteralExpression) { + var seen: Map = {}; + var Property = 1; + var GetAccessor = 2; + var SetAccesor = 4; + var GetOrSetAccessor = GetAccessor | SetAccesor; + var inStrictMode = (node.parserContextFlags & ParserContextFlags.StrictMode) !== 0; + + for (var i = 0, n = node.properties.length; i < n; i++) { + var prop = node.properties[i]; + var name = prop.name; + if (prop.kind === SyntaxKind.OmittedExpression || name.kind === SyntaxKind.ComputedPropertyName) { + continue; + } + + // ECMA-262 11.1.5 Object Initialiser + // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true + // a.This production is contained in strict code and IsDataDescriptor(previous) is true and + // IsDataDescriptor(propId.descriptor) is true. + // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. + // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. + // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true + // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields + var currentKind: number; + if (prop.kind === SyntaxKind.PropertyAssignment || + prop.kind === SyntaxKind.ShorthandPropertyAssignment || + prop.kind === SyntaxKind.MethodDeclaration) { + currentKind = Property; + } + else if (prop.kind === SyntaxKind.GetAccessor) { + currentKind = GetAccessor; + } + else if (prop.kind === SyntaxKind.SetAccessor) { + currentKind = SetAccesor; + } + else { + Debug.fail("Unexpected syntax kind:" + prop.kind); + } + + if (!hasProperty(seen, (name).text)) { + seen[(name).text] = currentKind; + } + else { + var existingKind = seen[(name).text]; + if (currentKind === Property && existingKind === Property) { + if (inStrictMode) { + grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); + } + } + else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { + if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { + seen[(name).text] = currentKind | existingKind; + } + else { + return grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + } + } + else { + return grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + } + } + } + + // Grammar checking for computedPropertName + forEach(node.properties, prop => { + if (prop.name.kind === SyntaxKind.ComputedPropertyName) { + checkGrammarComputedPropertyName(prop.name); + } + }); + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1674af935ca..a740c5f9cb4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4657,7 +4657,7 @@ module ts { case SyntaxKind.MethodSignature: return checkMethod(node); case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(node); - case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(node); + //case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(node); case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); case SyntaxKind.Parameter: return checkParameter(node); case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); diff --git a/tests/baselines/reference/duplicateObjectLiteralProperty.errors.txt b/tests/baselines/reference/duplicateObjectLiteralProperty.errors.txt index 05dfdc82404..0dd5febe496 100644 --- a/tests/baselines/reference/duplicateObjectLiteralProperty.errors.txt +++ b/tests/baselines/reference/duplicateObjectLiteralProperty.errors.txt @@ -1,4 +1,3 @@ -tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS1118: An object literal cannot have multiple get/set accessors with the same name. tests/cases/compiler/duplicateObjectLiteralProperty.ts(2,5): error TS2300: Duplicate identifier 'a'. tests/cases/compiler/duplicateObjectLiteralProperty.ts(4,5): error TS2300: Duplicate identifier 'a'. tests/cases/compiler/duplicateObjectLiteralProperty.ts(5,5): error TS2300: Duplicate identifier '\u0061'. @@ -7,6 +6,7 @@ tests/cases/compiler/duplicateObjectLiteralProperty.ts(7,9): error TS2300: Dupli tests/cases/compiler/duplicateObjectLiteralProperty.ts(8,9): error TS2300: Duplicate identifier '"c"'. tests/cases/compiler/duplicateObjectLiteralProperty.ts(14,9): error TS2300: Duplicate identifier 'a'. tests/cases/compiler/duplicateObjectLiteralProperty.ts(15,9): error TS2300: Duplicate identifier 'a'. +tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS1118: An object literal cannot have multiple get/set accessors with the same name. tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS2300: Duplicate identifier 'a'. diff --git a/tests/baselines/reference/duplicatePropertiesInStrictMode.errors.txt b/tests/baselines/reference/duplicatePropertiesInStrictMode.errors.txt index 6ae8518677d..b3d868dbe7e 100644 --- a/tests/baselines/reference/duplicatePropertiesInStrictMode.errors.txt +++ b/tests/baselines/reference/duplicatePropertiesInStrictMode.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/duplicatePropertiesInStrictMode.ts(4,3): error TS1117: An object literal cannot have multiple properties with the same name in strict mode. tests/cases/compiler/duplicatePropertiesInStrictMode.ts(3,3): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/duplicatePropertiesInStrictMode.ts(4,3): error TS1117: An object literal cannot have multiple properties with the same name in strict mode. tests/cases/compiler/duplicatePropertiesInStrictMode.ts(4,3): error TS2300: Duplicate identifier 'x'. diff --git a/tests/baselines/reference/twoAccessorsWithSameName.errors.txt b/tests/baselines/reference/twoAccessorsWithSameName.errors.txt index 73261bfa072..2909db66af1 100644 --- a/tests/baselines/reference/twoAccessorsWithSameName.errors.txt +++ b/tests/baselines/reference/twoAccessorsWithSameName.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(24,9): error TS1118: An object literal cannot have multiple get/set accessors with the same name. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(2,9): error TS2300: Duplicate identifier 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(3,9): error TS2300: Duplicate identifier 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(7,9): error TS2300: Duplicate identifier 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(8,9): error TS2300: Duplicate identifier 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(19,9): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(24,9): error TS1118: An object literal cannot have multiple get/set accessors with the same name. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName.ts(24,9): error TS2300: Duplicate identifier 'x'. From 747eb7268d19abc1e90e5dd3200444ae72d376cb Mon Sep 17 00:00:00 2001 From: Yui T Date: Sat, 13 Dec 2014 14:08:27 -0800 Subject: [PATCH 39/74] Move garmmar checking: numericLiteral; there are still error from incomplete migration --- src/compiler/checker.ts | 15 ++++++++++++++- src/compiler/parser.ts | 2 +- tests/baselines/reference/literals.errors.txt | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 513e47e0747..e3d78092282 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7009,6 +7009,19 @@ module ts { return type; } + function checkNumericLiteral(node: LiteralExpression): Type { + // Grammar checking + if (node.flags & NodeFlags.OctalLiteral) { + if (node.parserContextFlags & ParserContextFlags.StrictMode) { + grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); + } + else if (compilerOptions.target >= ScriptTarget.ES5) { + grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + } + } + return numberType; + } + function checkExpressionWorker(node: Expression, contextualMapper: TypeMapper): Type { switch (node.kind) { case SyntaxKind.Identifier: @@ -7023,7 +7036,7 @@ module ts { case SyntaxKind.FalseKeyword: return booleanType; case SyntaxKind.NumericLiteral: - return numberType; + return checkNumericLiteral(node); case SyntaxKind.TemplateExpression: return checkTemplateExpression(node); case SyntaxKind.StringLiteral: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a740c5f9cb4..22028913157 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4658,7 +4658,7 @@ module ts { return checkMethod(node); case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(node); //case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(node); - case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); + //case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); case SyntaxKind.Parameter: return checkParameter(node); case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); diff --git a/tests/baselines/reference/literals.errors.txt b/tests/baselines/reference/literals.errors.txt index f33d26af7a4..d43e89bb4db 100644 --- a/tests/baselines/reference/literals.errors.txt +++ b/tests/baselines/reference/literals.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/expressions/literals/literals.ts(20,9): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/literals/literals.ts(25,10): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/literals/literals.ts(9,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/literals/literals.ts(9,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/literals/literals.ts(10,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/expressions/literals/literals.ts(10,21): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/conformance/expressions/literals/literals.ts(20,9): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/literals/literals.ts(25,10): error TS1085: Octal literals are not available when targeting ECMAScript 5 and higher. ==== tests/cases/conformance/expressions/literals/literals.ts (6 errors) ==== From fe92b5e736778ad8552205257ae9ca8d64dbd862 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sat, 13 Dec 2014 20:57:38 -0800 Subject: [PATCH 40/74] Move grammar checking: parameter; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 10 ++++++++++ src/compiler/parser.ts | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e3d78092282..3252c2e72f2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7101,6 +7101,16 @@ module ts { } function checkParameter(node: ParameterDeclaration) { + // Grammar checking + // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the + // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code + // or if its FunctionBody is strict code(11.1.5). + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a + // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) + if (!checkGrammarModifiers(node) && (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.name))) { + reportGrammarErrorOfInvalidUseInStrictMode(node.name); + } + checkVariableLikeDeclaration(node); var func = getContainingFunction(node); if (node.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 22028913157..3f4482b0f69 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4659,7 +4659,7 @@ module ts { case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(node); //case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(node); //case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); - case SyntaxKind.Parameter: return checkParameter(node); + //case SyntaxKind.Parameter: return checkParameter(node); case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); case SyntaxKind.PropertyDeclaration: @@ -5337,7 +5337,7 @@ module ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.ImportDeclaration: - case SyntaxKind.Parameter: + //case SyntaxKind.Parameter: break; default: return false; From 94d4ac28f98bbb20d9dafb20144f8345149c154d Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 14 Dec 2014 11:12:45 -0800 Subject: [PATCH 41/74] Move grammar checking: postfixUnaryExpression --- src/compiler/checker.ts | 8 ++++++++ src/compiler/parser.ts | 2 +- .../reference/unaryOperatorsInStrictMode.errors.txt | 8 ++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3252c2e72f2..d9911b97133 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6622,6 +6622,14 @@ module ts { } function checkPostfixUnaryExpression(node: PostfixUnaryExpression): Type { + // Grammar checking + // The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression + // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. + if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.operand)) { + reportGrammarErrorOfInvalidUseInStrictMode(node.operand); + } + var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3f4482b0f69..efa31e19d34 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4660,7 +4660,7 @@ module ts { //case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(node); //case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); //case SyntaxKind.Parameter: return checkParameter(node); - case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); + //case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: diff --git a/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt b/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt index 34fb760e320..24af4e340a4 100644 --- a/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt +++ b/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt @@ -2,17 +2,17 @@ tests/cases/compiler/unaryOperatorsInStrictMode.ts(3,3): error TS1100: Invalid u tests/cases/compiler/unaryOperatorsInStrictMode.ts(4,3): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(5,3): error TS1100: Invalid use of 'arguments' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(6,3): error TS1100: Invalid use of 'arguments' in strict mode. -tests/cases/compiler/unaryOperatorsInStrictMode.ts(7,1): error TS1100: Invalid use of 'eval' in strict mode. -tests/cases/compiler/unaryOperatorsInStrictMode.ts(8,1): error TS1100: Invalid use of 'eval' in strict mode. -tests/cases/compiler/unaryOperatorsInStrictMode.ts(9,1): error TS1100: Invalid use of 'arguments' in strict mode. -tests/cases/compiler/unaryOperatorsInStrictMode.ts(10,1): error TS1100: Invalid use of 'arguments' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(3,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/compiler/unaryOperatorsInStrictMode.ts(4,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/compiler/unaryOperatorsInStrictMode.ts(5,3): error TS2304: Cannot find name 'arguments'. tests/cases/compiler/unaryOperatorsInStrictMode.ts(6,3): error TS2304: Cannot find name 'arguments'. +tests/cases/compiler/unaryOperatorsInStrictMode.ts(7,1): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(7,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/compiler/unaryOperatorsInStrictMode.ts(8,1): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(8,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/compiler/unaryOperatorsInStrictMode.ts(9,1): error TS1100: Invalid use of 'arguments' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(9,1): error TS2304: Cannot find name 'arguments'. +tests/cases/compiler/unaryOperatorsInStrictMode.ts(10,1): error TS1100: Invalid use of 'arguments' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(10,1): error TS2304: Cannot find name 'arguments'. From e852f3379cd49f910f913899747f345138d4886b Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 14 Dec 2014 11:29:54 -0800 Subject: [PATCH 42/74] Move grammar checking: prefixUnaryExpression; There are still error from incomplete migration --- src/compiler/checker.ts | 10 ++++++++++ src/compiler/parser.ts | 2 +- .../reference/unaryOperatorsInStrictMode.errors.txt | 6 +++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d9911b97133..defdde238fb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6599,6 +6599,16 @@ module ts { } function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { + // Grammar checking + if (node.parserContextFlags & ParserContextFlags.StrictMode) { + // The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression + // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator + if ((node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) && isEvalOrArgumentsIdentifier(node.operand)) { + reportGrammarErrorOfInvalidUseInStrictMode(node.operand); + } + } + var operandType = checkExpression(node.operand); switch (node.operator) { case SyntaxKind.PlusToken: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index efa31e19d34..f24bb111db9 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4661,7 +4661,7 @@ module ts { //case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); //case SyntaxKind.Parameter: return checkParameter(node); //case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); - case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); + //case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: return checkProperty(node); diff --git a/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt b/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt index 24af4e340a4..53263e7c2e1 100644 --- a/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt +++ b/tests/baselines/reference/unaryOperatorsInStrictMode.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/unaryOperatorsInStrictMode.ts(3,3): error TS1100: Invalid use of 'eval' in strict mode. -tests/cases/compiler/unaryOperatorsInStrictMode.ts(4,3): error TS1100: Invalid use of 'eval' in strict mode. -tests/cases/compiler/unaryOperatorsInStrictMode.ts(5,3): error TS1100: Invalid use of 'arguments' in strict mode. -tests/cases/compiler/unaryOperatorsInStrictMode.ts(6,3): error TS1100: Invalid use of 'arguments' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(3,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/compiler/unaryOperatorsInStrictMode.ts(4,3): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(4,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. +tests/cases/compiler/unaryOperatorsInStrictMode.ts(5,3): error TS1100: Invalid use of 'arguments' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(5,3): error TS2304: Cannot find name 'arguments'. +tests/cases/compiler/unaryOperatorsInStrictMode.ts(6,3): error TS1100: Invalid use of 'arguments' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(6,3): error TS2304: Cannot find name 'arguments'. tests/cases/compiler/unaryOperatorsInStrictMode.ts(7,1): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/unaryOperatorsInStrictMode.ts(7,1): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. From eadcc06fa33ee217ea87b05b7f436d00677f4188 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 14 Dec 2014 15:18:54 -0800 Subject: [PATCH 43/74] Move grammar checking: returnStatement; there are still error from incomplet grammar migration --- src/compiler/checker.ts | 28 +++++++++++++++++++ src/compiler/parser.ts | 2 +- .../reference/parserNotRegex1.errors.txt | 2 +- .../reference/parserWithStatement2.errors.txt | 2 +- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index defdde238fb..298eebc1a5a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8126,6 +8126,20 @@ module ts { } function checkReturnStatement(node: ReturnStatement) { + // Grammar checking + var parent = node.parent; + var inFunctionBlock = false; + while (parent && parent.kind !== SyntaxKind.SourceFile) { + inFunctionBlock = isFunctionBlock(parent); + if (inFunctionBlock) { + break; + } + parent = parent.parent; + } + if (!inFunctionBlock) { + grammarErrorOnFirstToken(node, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); + } + if (node.expression) { var func = getContainingFunction(node); if (func) { @@ -8149,6 +8163,20 @@ module ts { } function checkWithStatement(node: WithStatement) { + // Grammar checking + if (node.statement.kind === SyntaxKind.ReturnStatement) { + // Grammar check for invalid use of return statement + grammarErrorOnFirstToken(node.statement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); + } + else if (node.statement.kind === SyntaxKind.Block) { + forEach((node.statement).statements, statement => { + if (statement.kind === SyntaxKind.ReturnStatement) { + // Grammar check for invalid use of return statement + grammarErrorOnFirstToken(node.statement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); + } + }); + } + checkExpression(node.expression); error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f24bb111db9..ed0aec3c501 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4665,7 +4665,7 @@ module ts { case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: return checkProperty(node); - case SyntaxKind.ReturnStatement: return checkReturnStatement(node); + //case SyntaxKind.ReturnStatement: return checkReturnStatement(node); case SyntaxKind.SetAccessor: return checkSetAccessor(node); case SyntaxKind.SourceFile: return checkSourceFile(node); case SyntaxKind.ShorthandPropertyAssignment: return checkShorthandPropertyAssignment(node); diff --git a/tests/baselines/reference/parserNotRegex1.errors.txt b/tests/baselines/reference/parserNotRegex1.errors.txt index 9e592541fd0..7eb06157dfc 100644 --- a/tests/baselines/reference/parserNotRegex1.errors.txt +++ b/tests/baselines/reference/parserNotRegex1.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/parser/ecmascript5/parserNotRegex1.ts(3,5): error TS1108: A 'return' statement can only be used within a function body. tests/cases/conformance/parser/ecmascript5/parserNotRegex1.ts(1,7): error TS2304: Cannot find name 'a'. +tests/cases/conformance/parser/ecmascript5/parserNotRegex1.ts(3,5): error TS1108: A 'return' statement can only be used within a function body. ==== tests/cases/conformance/parser/ecmascript5/parserNotRegex1.ts (2 errors) ==== diff --git a/tests/baselines/reference/parserWithStatement2.errors.txt b/tests/baselines/reference/parserWithStatement2.errors.txt index 47ad0c8a920..c2d4b2efa96 100644 --- a/tests/baselines/reference/parserWithStatement2.errors.txt +++ b/tests/baselines/reference/parserWithStatement2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts(2,3): error TS1108: A 'return' statement can only be used within a function body. tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts(1,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. +tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts(2,3): error TS1108: A 'return' statement can only be used within a function body. ==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts (2 errors) ==== From 1cc0d184bb9a9483c65d810e085eaf04b4288c92 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 14 Dec 2014 19:14:02 -0800 Subject: [PATCH 44/74] Move grammar checking: shorthandPropertyAssignment; Add more parser test; there are still errors from incomplete migration --- src/compiler/checker.ts | 5 ++++- src/compiler/parser.ts | 2 +- .../parserShorthandPropertyAssignment1.errors.txt | 12 ++++++++++++ .../parserShorthandPropertyAssignment2.errors.txt | 7 +++++++ .../parserShorthandPropertyAssignment3.errors.txt | 7 +++++++ .../parserShorthandPropertyAssignment4.errors.txt | 7 +++++++ .../parserShorthandPropertyAssignment5.errors.txt | 8 ++++++++ .../parserShorthandPropertyAssignment1.ts | 3 +++ .../parserShorthandPropertyAssignment2.ts | 1 + .../parserShorthandPropertyAssignment3.ts | 1 + .../parserShorthandPropertyAssignment4.ts | 1 + .../parserShorthandPropertyAssignment5.ts | 2 ++ 12 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/parserShorthandPropertyAssignment1.errors.txt create mode 100644 tests/baselines/reference/parserShorthandPropertyAssignment2.errors.txt create mode 100644 tests/baselines/reference/parserShorthandPropertyAssignment3.errors.txt create mode 100644 tests/baselines/reference/parserShorthandPropertyAssignment4.errors.txt create mode 100644 tests/baselines/reference/parserShorthandPropertyAssignment5.errors.txt create mode 100644 tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment1.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment2.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment3.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment4.ts create mode 100644 tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment5.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 298eebc1a5a..8fe31a0c5ce 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10274,11 +10274,14 @@ module ts { } } - // Grammar checking for computedPropertName + // Grammar checking for computedPropertName and shorthandPropertyAssignment forEach(node.properties, prop => { if (prop.name.kind === SyntaxKind.ComputedPropertyName) { checkGrammarComputedPropertyName(prop.name); } + else if (prop.kind === SyntaxKind.ShorthandPropertyAssignment) { + checkGrammarForInvalidQuestionMark(prop, (prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); + } }); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ed0aec3c501..fa2df653765 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4668,7 +4668,7 @@ module ts { //case SyntaxKind.ReturnStatement: return checkReturnStatement(node); case SyntaxKind.SetAccessor: return checkSetAccessor(node); case SyntaxKind.SourceFile: return checkSourceFile(node); - case SyntaxKind.ShorthandPropertyAssignment: return checkShorthandPropertyAssignment(node); + //case SyntaxKind.ShorthandPropertyAssignment: return checkShorthandPropertyAssignment(node); case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); case SyntaxKind.ThrowStatement: return checkThrowStatement(node); diff --git a/tests/baselines/reference/parserShorthandPropertyAssignment1.errors.txt b/tests/baselines/reference/parserShorthandPropertyAssignment1.errors.txt new file mode 100644 index 00000000000..b877d853bdd --- /dev/null +++ b/tests/baselines/reference/parserShorthandPropertyAssignment1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment1.ts(3,11): error TS1162: An object member cannot be declared optional. +tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment1.ts(3,16): error TS1162: An object member cannot be declared optional. + + +==== tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment1.ts (2 errors) ==== + function foo(obj: { name?: string; id: number }) { } + var name:any, id: any; + foo({ name?, id? }); + ~ +!!! error TS1162: An object member cannot be declared optional. + ~ +!!! error TS1162: An object member cannot be declared optional. \ No newline at end of file diff --git a/tests/baselines/reference/parserShorthandPropertyAssignment2.errors.txt b/tests/baselines/reference/parserShorthandPropertyAssignment2.errors.txt new file mode 100644 index 00000000000..d6841652600 --- /dev/null +++ b/tests/baselines/reference/parserShorthandPropertyAssignment2.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment2.ts(1,17): error TS1005: ':' expected. + + +==== tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment2.ts (1 errors) ==== + var v = { class }; + ~ +!!! error TS1005: ':' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserShorthandPropertyAssignment3.errors.txt b/tests/baselines/reference/parserShorthandPropertyAssignment3.errors.txt new file mode 100644 index 00000000000..aa8fbfb2beb --- /dev/null +++ b/tests/baselines/reference/parserShorthandPropertyAssignment3.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment3.ts(1,14): error TS1005: ':' expected. + + +==== tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment3.ts (1 errors) ==== + var v = { "" }; + ~ +!!! error TS1005: ':' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserShorthandPropertyAssignment4.errors.txt b/tests/baselines/reference/parserShorthandPropertyAssignment4.errors.txt new file mode 100644 index 00000000000..8cadf423e19 --- /dev/null +++ b/tests/baselines/reference/parserShorthandPropertyAssignment4.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment4.ts(1,13): error TS1005: ':' expected. + + +==== tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment4.ts (1 errors) ==== + var v = { 0 }; + ~ +!!! error TS1005: ':' expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserShorthandPropertyAssignment5.errors.txt b/tests/baselines/reference/parserShorthandPropertyAssignment5.errors.txt new file mode 100644 index 00000000000..714881727b8 --- /dev/null +++ b/tests/baselines/reference/parserShorthandPropertyAssignment5.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment5.ts(2,18): error TS1162: An object member cannot be declared optional. + + +==== tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment5.ts (1 errors) ==== + var greet = "hello"; + var obj = { greet? }; + ~ +!!! error TS1162: An object member cannot be declared optional. \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment1.ts b/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment1.ts new file mode 100644 index 00000000000..9ef2f06cdfc --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment1.ts @@ -0,0 +1,3 @@ +function foo(obj: { name?: string; id: number }) { } +var name:any, id: any; +foo({ name?, id? }); \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment2.ts b/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment2.ts new file mode 100644 index 00000000000..ca28c05016b --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment2.ts @@ -0,0 +1 @@ +var v = { class }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment3.ts b/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment3.ts new file mode 100644 index 00000000000..de2a94b194e --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment3.ts @@ -0,0 +1 @@ +var v = { "" }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment4.ts b/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment4.ts new file mode 100644 index 00000000000..5479b23b32b --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment4.ts @@ -0,0 +1 @@ +var v = { 0 }; \ No newline at end of file diff --git a/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment5.ts b/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment5.ts new file mode 100644 index 00000000000..8f8e7902cd4 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment5.ts @@ -0,0 +1,2 @@ +var greet = "hello"; +var obj = { greet? }; \ No newline at end of file From a4f17b14176b472bdc50cd3c91fb6dc6b12c35f6 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 14 Dec 2014 19:57:12 -0800 Subject: [PATCH 45/74] Move grammar checking: switchStatement; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 18 ++++++++++++++++++ .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 ++- src/compiler/parser.ts | 3 ++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8fe31a0c5ce..737393486b2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8182,8 +8182,26 @@ module ts { } function checkSwitchStatement(node: SwitchStatement) { + // Grammar checking + var firstDefaultClause: CaseOrDefaultClause; + var hasDuplicateDefaultClause = false; + var expressionType = checkExpression(node.expression); forEach(node.clauses, clause => { + // Grammar check for duplicate default clauses, skip if we already report duplicate default clause + if (clause.kind === SyntaxKind.DefaultClause && !hasDuplicateDefaultClause) { + if (firstDefaultClause === undefined) { + firstDefaultClause = clause; + } + else { + var sourceFile = getSourceFileOfNode(node); + var start = skipTrivia(sourceFile.text, clause.pos); + var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; + grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + hasDuplicateDefaultClause = true; + } + } + if (fullTypeCheck && clause.kind === SyntaxKind.CaseClause) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index c9bf3883200..1a25fdcffe9 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -76,7 +76,7 @@ module ts { Type_expected: { code: 1110, category: DiagnosticCategory.Error, key: "Type expected.", isEarly: true }, A_constructor_implementation_cannot_be_declared_in_an_ambient_context: { code: 1111, category: DiagnosticCategory.Error, key: "A constructor implementation cannot be declared in an ambient context.", isEarly: true }, A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional.", isEarly: true }, - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement.", isEarly: true }, Duplicate_label_0: { code: 1114, category: DiagnosticCategory.Error, key: "Duplicate label '{0}'", isEarly: true }, A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement.", isEarly: true }, A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 240661277ee..390e6e79dc7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -347,7 +347,8 @@ }, "A 'default' clause cannot appear more than once in a 'switch' statement.": { "category": "Error", - "code": 1113 + "code": 1113, + "isEarly": true }, "Duplicate label '{0}'": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index fa2df653765..d8f6cf636f3 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4669,7 +4669,7 @@ module ts { case SyntaxKind.SetAccessor: return checkSetAccessor(node); case SyntaxKind.SourceFile: return checkSourceFile(node); //case SyntaxKind.ShorthandPropertyAssignment: return checkShorthandPropertyAssignment(node); - case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); + //case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); case SyntaxKind.ThrowStatement: return checkThrowStatement(node); case SyntaxKind.TypeReference: return checkTypeReference(node); @@ -5694,6 +5694,7 @@ module ts { var start = skipTrivia(file.text, clause.pos); var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; return grammarErrorAtPos(start, end - start, Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + } } } From b388eb3c2a1c5a7991cedfe8ee334883e2146c40 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 14 Dec 2014 21:12:14 -0800 Subject: [PATCH 46/74] Move grammar checking: taggedTemplateExpression --- src/compiler/checker.ts | 5 +++++ .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 ++- src/compiler/parser.ts | 2 +- ...mplateStringsTypeArgumentInference.errors.txt | 16 ++++++++-------- ...lateStringsWithOverloadResolution1.errors.txt | 12 ++++++------ ...lateStringsWithOverloadResolution3.errors.txt | 16 ++++++++-------- ...teStringsArrayTypeDefinedInES5Mode.errors.txt | 2 +- ...eStringsArrayTypeNotDefinedES5Mode.errors.txt | 2 +- 9 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 737393486b2..edf1a01ad3b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6303,6 +6303,11 @@ module ts { } function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type { + // Grammar checking + if (compilerOptions.target < ScriptTarget.ES6) { + grammarErrorOnFirstToken(node.template, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + return getReturnTypeOfSignature(getResolvedSignature(node)); } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 1a25fdcffe9..b2209d41677 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -119,7 +119,7 @@ module ts { const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized", isEarly: true }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block.", isEarly: true }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block.", isEarly: true }, - Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, + Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher.", isEarly: true }, Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 390e6e79dc7..9651742d437 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -540,7 +540,8 @@ }, "Tagged templates are only available when targeting ECMAScript 6 and higher.": { "category": "Error", - "code": 1159 + "code": 1159, + "isEarly": true }, "Unterminated template literal.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d8f6cf636f3..162f895fe09 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4670,7 +4670,7 @@ module ts { case SyntaxKind.SourceFile: return checkSourceFile(node); //case SyntaxKind.ShorthandPropertyAssignment: return checkShorthandPropertyAssignment(node); //case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); - case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); + //case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); case SyntaxKind.ThrowStatement: return checkThrowStatement(node); case SyntaxKind.TypeReference: return checkTypeReference(node); case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt index ac184e9489f..99e90d57148 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt @@ -21,15 +21,15 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(53,15): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(57,23): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(58,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. + Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. + Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(81,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(86,23): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(90,25): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts (30 errors) ==== @@ -143,11 +143,11 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference return null; } var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. + ~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var a9a: {}; // Generic tag with multiple parameters of generic type passed arguments with multiple best common types @@ -161,11 +161,11 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference } var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`; - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. + ~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var a9e: {}; // Generic tag with multiple parameters of generic type passed arguments with a single best common type diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt index bb5b56578df..e4c79537ce2 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt @@ -1,13 +1,13 @@ +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(16,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(17,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(18,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(20,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(20,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts (10 errors) ==== @@ -48,8 +48,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio ~~~ !!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var z = foo `${1}${2}${3}`; // any (with error) - ~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. + ~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt index 3ffe3d5820d..c1a6b228b01 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt @@ -1,7 +1,9 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(7,21): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(10,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(10,9): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(16,20): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(17,20): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(19,4): error TS2339: Property 'foo' does not exist on type 'Date'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(23,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(26,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(34,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. @@ -10,6 +12,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(40,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(41,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(42,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(45,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(45,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(54,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(55,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. @@ -17,15 +20,12 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(57,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(60,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(63,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(70,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(71,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(10,9): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(19,4): error TS2339: Property 'foo' does not exist on type 'Date'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(45,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(63,9): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,18): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(70,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(70,18): error TS2339: Property 'toFixed' does not exist on type 'string'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(71,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts (28 errors) ==== @@ -102,10 +102,10 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio // Generic overloads with differing arity tagging with argument count that doesn't match any overload fn3 ``; // Error - ~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. + ~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. // Generic overloads with constraints function fn4(strs: TemplateStringsArray, n: T, m: U); diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index dc494c7c3f4..61b82bcb459 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(10,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. lib.d.ts(515,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{ [x: number]: undefined; }'. +tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(10,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (3 errors) ==== diff --git a/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt index 56793bf95ad..b233ad963c7 100644 --- a/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(7,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(5,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{ [x: number]: undefined; }'. +tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts(7,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ==== tests/cases/compiler/templateStringsArrayTypeNotDefinedES5Mode.ts (2 errors) ==== From 98cb805f138d829d82983903dd1874af2da3e7d1 Mon Sep 17 00:00:00 2001 From: Yui T Date: Sun, 14 Dec 2014 22:50:58 -0800 Subject: [PATCH 47/74] Move grammar check: throwStatement; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 13 +++++++++++++ src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 ++- src/compiler/parser.ts | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index edf1a01ad3b..10abc5601af 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8241,6 +8241,10 @@ module ts { } function checkThrowStatement(node: ThrowStatement) { + if (node.expression === undefined) { + grammarErrorAfterFirstToken(getSourceFileOfNode(node), node, Diagnostics.Line_break_not_permitted_here); + } + if (node.expression) { checkExpression(node.expression); } @@ -10353,6 +10357,15 @@ module ts { return grammarErrorOnNode(node, Diagnostics.Invalid_use_of_0_in_strict_mode, name); } + function grammarErrorAfterFirstToken(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { + if (!hasParseDiagnostics(sourceFile)) { + var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text); + scanToken(scanner, node.pos); + diagnostics.push(createFileDiagnostic(sourceFile, scanner.getTextPos(), 0, message, arg0, arg1, arg2)); + return true; + } + } + initializeTypeChecker(); return checker; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index b2209d41677..2050bad5ca5 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -105,7 +105,7 @@ module ts { Type_parameter_declaration_expected: { code: 1139, category: DiagnosticCategory.Error, key: "Type parameter declaration expected." }, Type_argument_expected: { code: 1140, category: DiagnosticCategory.Error, key: "Type argument expected." }, String_literal_expected: { code: 1141, category: DiagnosticCategory.Error, key: "String literal expected.", isEarly: true }, - Line_break_not_permitted_here: { code: 1142, category: DiagnosticCategory.Error, key: "Line break not permitted here." }, + Line_break_not_permitted_here: { code: 1142, category: DiagnosticCategory.Error, key: "Line break not permitted here.", isEarly: true }, or_expected: { code: 1144, category: DiagnosticCategory.Error, key: "'{' or ';' expected." }, Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members.", isEarly: true }, Declaration_expected: { code: 1146, category: DiagnosticCategory.Error, key: "Declaration expected." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9651742d437..2cef9250a8f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -476,7 +476,8 @@ }, "Line break not permitted here.": { "category": "Error", - "code": 1142 + "code": 1142, + "isEarly": true }, "'{' or ';' expected.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 162f895fe09..41ccdfd3dc3 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4671,7 +4671,7 @@ module ts { //case SyntaxKind.ShorthandPropertyAssignment: return checkShorthandPropertyAssignment(node); //case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); //case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); - case SyntaxKind.ThrowStatement: return checkThrowStatement(node); + //case SyntaxKind.ThrowStatement: return checkThrowStatement(node); case SyntaxKind.TypeReference: return checkTypeReference(node); case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); case SyntaxKind.VariableStatement: return checkVariableStatement(node); From 5d91394713910e48e32932f9bbfe8489affbf329 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 10:15:12 -0800 Subject: [PATCH 48/74] Movev grammar checking: typeReference; there are still errors from incomplet grammar migration --- src/compiler/checker.ts | 7 +++++-- src/compiler/parser.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 10abc5601af..ae7fc25c7e4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7363,6 +7363,9 @@ module ts { } function checkTypeReference(node: TypeReferenceNode) { + // Grammar checking + checkGrammarTypeArguments(node, node.typeArguments); + var type = getTypeFromTypeReferenceNode(node); if (type !== unknownType && node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved @@ -10082,7 +10085,7 @@ module ts { checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); } - function checkGrammarForAtLeastOneTypeArgument(node: CallExpression, typeArguments: NodeArray): boolean { + function checkGrammarForAtLeastOneTypeArgument(node: Node, typeArguments: NodeArray): boolean { if (typeArguments && typeArguments.length === 0) { var sourceFile = getSourceFileOfNode(node); var start = typeArguments.pos - "<".length; @@ -10091,7 +10094,7 @@ module ts { } } - function checkGrammarTypeArguments(node: CallExpression, typeArguments: NodeArray): boolean { + function checkGrammarTypeArguments(node: Node, typeArguments: NodeArray): boolean { return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 41ccdfd3dc3..c1ec9a113a7 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4672,7 +4672,7 @@ module ts { //case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); //case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); //case SyntaxKind.ThrowStatement: return checkThrowStatement(node); - case SyntaxKind.TypeReference: return checkTypeReference(node); + //case SyntaxKind.TypeReference: return checkTypeReference(node); case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); case SyntaxKind.VariableStatement: return checkVariableStatement(node); case SyntaxKind.WithStatement: return checkWithStatement(node); From 896f172d72a594ed9e36fa62c4d7cf26ee890789 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 10:15:46 -0800 Subject: [PATCH 49/74] Move grammar checking: wihtStatement; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 7 ++++++- src/compiler/parser.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ae7fc25c7e4..cc73dca16ed 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8171,7 +8171,12 @@ module ts { } function checkWithStatement(node: WithStatement) { - // Grammar checking + // Grammar checking for withStatement + if (node.parserContextFlags & ParserContextFlags.StrictMode) { + grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } + + // Grammar checking for invalid use of return statement if (node.statement.kind === SyntaxKind.ReturnStatement) { // Grammar check for invalid use of return statement grammarErrorOnFirstToken(node.statement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c1ec9a113a7..29b91a434a7 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4675,7 +4675,7 @@ module ts { //case SyntaxKind.TypeReference: return checkTypeReference(node); case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); case SyntaxKind.VariableStatement: return checkVariableStatement(node); - case SyntaxKind.WithStatement: return checkWithStatement(node); + //case SyntaxKind.WithStatement: return checkWithStatement(node); case SyntaxKind.YieldExpression: return checkYieldExpression(node); } } From aa59b4d3f11d8911cfb22ef59ab2eced97c518e6 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 10:47:42 -0800 Subject: [PATCH 50/74] Move grammar checking: yieldExpression; there are still error from incomplete grammar migration. --- src/compiler/checker.ts | 13 +++++++++++++ src/compiler/parser.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cc73dca16ed..6b662cf70f0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6936,6 +6936,16 @@ module ts { } } + function checkYieldExpression(node: YieldExpression): void { + // Grammar checking + if (!(node.parserContextFlags & ParserContextFlags.Yield)) { + grammarErrorOnFirstToken(node, Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration); + } + else { + grammarErrorOnFirstToken(node, Diagnostics.yield_expressions_are_not_currently_supported); + } + } + function checkConditionalExpression(node: ConditionalExpression, contextualMapper?: TypeMapper): Type { checkExpression(node.condition); var type1 = checkExpression(node.whenTrue, contextualMapper); @@ -7103,6 +7113,9 @@ module ts { return checkConditionalExpression(node, contextualMapper); case SyntaxKind.OmittedExpression: return undefinedType; + case SyntaxKind.YieldExpression: + checkYieldExpression(node); + return unknownType; } return unknownType; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 29b91a434a7..2763340551a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4676,7 +4676,7 @@ module ts { case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); case SyntaxKind.VariableStatement: return checkVariableStatement(node); //case SyntaxKind.WithStatement: return checkWithStatement(node); - case SyntaxKind.YieldExpression: return checkYieldExpression(node); + //case SyntaxKind.YieldExpression: return checkYieldExpression(node); } } From e49470bf86842af79c694b7d61a0849e8988b7db Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 14:16:11 -0800 Subject: [PATCH 51/74] Address code review --- src/compiler/checker.ts | 110 ++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 67 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6b662cf70f0..972290095ed 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5374,9 +5374,6 @@ module ts { if (member.flags & SymbolFlags.Property || isObjectLiteralMethod(member.declarations[0])) { var memberDecl = member.declarations[0]; if (memberDecl.kind === SyntaxKind.PropertyAssignment) { - // Grammar checking - checkGrammarForInvalidQuestionMark(memberDecl,(memberDecl).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); - var type = checkExpression((memberDecl).initializer, contextualMapper); } else if (memberDecl.kind === SyntaxKind.MethodDeclaration) { @@ -6605,13 +6602,11 @@ module ts { function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { // Grammar checking - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator - if ((node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) && isEvalOrArgumentsIdentifier(node.operand)) { - reportGrammarErrorOfInvalidUseInStrictMode(node.operand); - } + // The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression + // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator + if ((node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken)) { + checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); } var operandType = checkExpression(node.operand); @@ -6641,9 +6636,7 @@ module ts { // The identifier eval or arguments may not appear as the LeftHandSideExpression of an // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. - if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.operand)) { - reportGrammarErrorOfInvalidUseInStrictMode(node.operand); - } + checkGrammarEvalOrArgumentsInStrictMode(node, node.operand); var operandType = checkExpression(node.operand); var ok = checkArithmeticOperandType(node.operand, operandType, Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); @@ -6772,14 +6765,10 @@ module ts { function checkBinaryExpression(node: BinaryExpression, contextualMapper?: TypeMapper) { // Grammar checking - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) { - if (isEvalOrArgumentsIdentifier(node.left)) { - // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) - reportGrammarErrorOfInvalidUseInStrictMode(node.left); - } - } + if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) { + // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an + // Assignment operator(11.13) or of a PostfixExpression(11.3) + checkGrammarEvalOrArgumentsInStrictMode(node, node.left); } var operator = node.operator; @@ -7143,8 +7132,8 @@ module ts { // or if its FunctionBody is strict code(11.1.5). // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) - if (!checkGrammarModifiers(node) && (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.name))) { - reportGrammarErrorOfInvalidUseInStrictMode(node.name); + if (!checkGrammarModifiers(node)) { + checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } checkVariableLikeDeclaration(node); @@ -8281,11 +8270,10 @@ module ts { var colonStart = skipTrivia(sourceFile.text, catchClause.name.end); grammarErrorAtPos(sourceFile, colonStart, ":".length, Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation); } - if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(catchClause.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(catchClause.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 + checkGrammarEvalOrArgumentsInStrictMode(node, catchClause.name); + checkBlock(catchClause.block); } if (node.finallyBlock) checkBlock(node.finallyBlock); @@ -10135,11 +10123,9 @@ module ts { } function checkGrammarBindingElement(node: BindingElement) { - if (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(node.name); - } + // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code + // and its Identifier is eval or arguments + checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } function checkGrammarHeritageClause(node: HeritageClause): boolean { @@ -10147,8 +10133,8 @@ module ts { if (checkGrammarForDisallowedTrailingComma(types)) { return true; } - var listType = tokenToString(node.token); if (types && types.length === 0) { + var listType = tokenToString(node.token); var sourceFile = getSourceFileOfNode(node); return grammarErrorAtPos(sourceFile, types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType) } @@ -10165,18 +10151,15 @@ module ts { if (heritageClause.token === SyntaxKind.ExtendsKeyword) { if (seenExtendsClause) { - grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen) - break; + return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen) } if (seenImplementsClause) { - grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_must_precede_implements_clause); - break; + return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_must_precede_implements_clause); } if (heritageClause.types.length > 1) { - grammarErrorOnFirstToken(heritageClause.types[1], Diagnostics.Classes_can_only_extend_a_single_class); - break; + return grammarErrorOnFirstToken(heritageClause.types[1], Diagnostics.Classes_can_only_extend_a_single_class); } seenExtendsClause = true; @@ -10184,8 +10167,7 @@ module ts { else { Debug.assert(heritageClause.token === SyntaxKind.ImplementsKeyword); if (seenImplementsClause) { - grammarErrorOnFirstToken(heritageClause, Diagnostics.implements_clause_already_seen); - break; + return grammarErrorOnFirstToken(heritageClause, Diagnostics.implements_clause_already_seen); } seenImplementsClause = true; @@ -10246,11 +10228,8 @@ module ts { } function checkGrammarFunctionName(name: Node) { - if (name && name.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(name)) { - // It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the - // Identifier of a FunctionLikeDeclaration or FunctionExpression or as a formal parameter name(13.1) - return reportGrammarErrorOfInvalidUseInStrictMode(name); - } + // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) + return checkGrammarEvalOrArgumentsInStrictMode(name, name); } function checkGrammarForInvalidQuestionMark(node: Declaration, questionToken: Node, message: DiagnosticMessage): boolean { @@ -10268,9 +10247,13 @@ module ts { var inStrictMode = (node.parserContextFlags & ParserContextFlags.StrictMode) !== 0; for (var i = 0, n = node.properties.length; i < n; i++) { - var prop = node.properties[i]; + var prop = node.properties[i]; var name = prop.name; - if (prop.kind === SyntaxKind.OmittedExpression || name.kind === SyntaxKind.ComputedPropertyName) { + if (prop.kind === SyntaxKind.OmittedExpression) { + continue; + } + else if (name.kind === SyntaxKind.ComputedPropertyName) { + checkGrammarComputedPropertyName(name); continue; } @@ -10283,9 +10266,12 @@ module ts { // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind: number; - if (prop.kind === SyntaxKind.PropertyAssignment || - prop.kind === SyntaxKind.ShorthandPropertyAssignment || - prop.kind === SyntaxKind.MethodDeclaration) { + if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) { + // Grammar checking for computedPropertName and shorthandPropertyAssignment + checkGrammarForInvalidQuestionMark(prop,(prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); + currentKind = Property; + } + else if ( prop.kind === SyntaxKind.MethodDeclaration) { currentKind = Property; } else if (prop.kind === SyntaxKind.GetAccessor) { @@ -10321,16 +10307,6 @@ module ts { } } } - - // Grammar checking for computedPropertName and shorthandPropertyAssignment - forEach(node.properties, prop => { - if (prop.name.kind === SyntaxKind.ComputedPropertyName) { - checkGrammarComputedPropertyName(prop.name); - } - else if (prop.kind === SyntaxKind.ShorthandPropertyAssignment) { - checkGrammarForInvalidQuestionMark(prop, (prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); - } - }); } function hasParseDiagnostics(sourceFile: SourceFile): boolean { @@ -10371,11 +10347,11 @@ module ts { } } - function reportGrammarErrorOfInvalidUseInStrictMode(node: Identifier): boolean { - //var sourceText = getSourceFileOfNode(node).text; - //var name = sourceText.substring(skipTrivia(sourceText, node.pos), node.end); - var name = declarationNameToString(node); - return grammarErrorOnNode(node, Diagnostics.Invalid_use_of_0_in_strict_mode, name); + function checkGrammarEvalOrArgumentsInStrictMode(contextNode: Node, identifier: Identifier): boolean { + if (contextNode && (contextNode.parserContextFlags & ParserContextFlags.StrictMode) && isEvalOrArgumentsIdentifier(identifier)) { + var name = declarationNameToString(identifier); + return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, name); + } } function grammarErrorAfterFirstToken(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { From d584737ea2afab9a42fc7ec44e4170e836e8e90b Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 14:47:09 -0800 Subject: [PATCH 52/74] Address code review --- src/compiler/checker.ts | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 972290095ed..d4376becd6a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8139,14 +8139,8 @@ module ts { // Grammar checking var parent = node.parent; var inFunctionBlock = false; - while (parent && parent.kind !== SyntaxKind.SourceFile) { - inFunctionBlock = isFunctionBlock(parent); - if (inFunctionBlock) { - break; - } - parent = parent.parent; - } - if (!inFunctionBlock) { + var functionBlock = getContainingFunction(node); + if (!functionBlock) { grammarErrorOnFirstToken(node, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); } @@ -8174,21 +8168,16 @@ module ts { function checkWithStatement(node: WithStatement) { // Grammar checking for withStatement + var hasStrictModeError = false; if (node.parserContextFlags & ParserContextFlags.StrictMode) { grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); + hasStrictModeError = true; } // Grammar checking for invalid use of return statement - if (node.statement.kind === SyntaxKind.ReturnStatement) { - // Grammar check for invalid use of return statement - grammarErrorOnFirstToken(node.statement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); - } - else if (node.statement.kind === SyntaxKind.Block) { - forEach((node.statement).statements, statement => { - if (statement.kind === SyntaxKind.ReturnStatement) { - // Grammar check for invalid use of return statement - grammarErrorOnFirstToken(node.statement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); - } + if (!hasStrictModeError) { + forEachReturnStatement(node.statement, (returnStatement) => { + grammarErrorOnFirstToken(returnStatement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); }); } From 60eb37df94b9e6cc2aa76910171e6c82dc67ecb0 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 14:51:52 -0800 Subject: [PATCH 53/74] Move grammar checking: declare keyword in checkGrammarModifier; there are still erros from incomplete grammar migration --- src/compiler/checker.ts | 15 ++++++++++++++- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d4376becd6a..8983725d206 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9947,7 +9947,20 @@ module ts { break; case SyntaxKind.DeclareKeyword: - // TODO (yuisu) : Revisit this once moving ambient Context into type checking + if (flags & NodeFlags.Ambient) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "declare"); + } + else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); + } + else if (node.kind === SyntaxKind.Parameter) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); + } + else if (isInAmbientContext(node.parent) && node.parent.kind === SyntaxKind.ModuleBlock) { + return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); + } + flags |= NodeFlags.Ambient; + lastDeclare = modifier break; } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 2050bad5ca5..fa21ddd03d4 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -33,7 +33,7 @@ module ts { Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names.", isEarly: true }, Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts.", isEarly: true }, A_function_implementation_cannot_be_declared_in_an_ambient_context: { code: 1037, category: DiagnosticCategory.Error, key: "A function implementation cannot be declared in an ambient context.", isEarly: true }, - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context.", isEarly: true }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts.", isEarly: true }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element.", isEarly: true }, A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 2cef9250a8f..3ddd6cf2a84 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -144,7 +144,8 @@ }, "A 'declare' modifier cannot be used in an already ambient context.": { "category": "Error", - "code": 1038 + "code": 1038, + "isEarly": true }, "Initializers are not allowed in ambient contexts.": { "category": "Error", From 28a115ef37931211bb27204d5833561ddc62e4a8 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 15:05:31 -0800 Subject: [PATCH 54/74] Move grammar checking: breakStatement, continueStatement; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 71 +++++++++++++++++++ src/compiler/parser.ts | 6 +- .../invalidDoWhileBreakStatements.errors.txt | 4 +- ...nvalidDoWhileContinueStatements.errors.txt | 4 +- .../invalidForBreakStatements.errors.txt | 4 +- .../invalidForContinueStatements.errors.txt | 4 +- .../invalidForInBreakStatements.errors.txt | 4 +- .../invalidForInContinueStatements.errors.txt | 4 +- .../invalidWhileBreakStatements.errors.txt | 4 +- .../invalidWhileContinueStatements.errors.txt | 4 +- 10 files changed, 90 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8983725d206..a77da719e52 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8128,6 +8128,9 @@ module ts { } function checkBreakOrContinueStatement(node: BreakOrContinueStatement) { + // Grammar checking + checkGrammarBreakOrContinueStatement(node); + // TODO: Check that target label is valid } @@ -10311,6 +10314,74 @@ module ts { } } + function isIterationStatement(node: Node, lookInLabeledStatements: boolean): boolean { + switch (node.kind) { + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + return true; + case SyntaxKind.LabeledStatement: + return lookInLabeledStatements && isIterationStatement((node).statement, lookInLabeledStatements); + } + + return false; + } + + function checkGrammarBreakOrContinueStatement(node: BreakOrContinueStatement): boolean { + var current: Node = node; + while (current) { + if (isAnyFunction(current)) { + return grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary); + } + + switch (current.kind) { + case SyntaxKind.LabeledStatement: + if (node.label && (current).label.text === node.label.text) { + // found matching label - verify that label usage is correct + // continue can only target labels that are on iteration statements + var isMisplacedContinueLabel = node.kind === SyntaxKind.ContinueStatement + && !isIterationStatement((current).statement, /*lookInLabeledStatement*/ true); + + if (isMisplacedContinueLabel) { + return grammarErrorOnNode(node, Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); + } + + return false; + } + break; + case SyntaxKind.SwitchStatement: + if (node.kind === SyntaxKind.BreakStatement && !node.label) { + // unlabeled break within switch statement - ok + return false; + } + break; + default: + if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { + // unlabeled break or continue within iteration statement - ok + return false; + } + break; + } + + current = current.parent; + } + + if (node.label) { + var message = node.kind === SyntaxKind.BreakStatement + ? Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement + : Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; + + return grammarErrorOnNode(node, message) + } + else { + var message = node.kind === SyntaxKind.BreakStatement + ? Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement + : Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; + return grammarErrorOnNode(node, message) + } + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 2763340551a..b2fbe11fcb5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4626,9 +4626,9 @@ module ts { function checkNode(node: Node, nodeKind: SyntaxKind): boolean { // Now do node specific checks. switch (nodeKind) { - case SyntaxKind.BreakStatement: - case SyntaxKind.ContinueStatement: - return checkBreakOrContinueStatement(node); + //case SyntaxKind.BreakStatement: + //case SyntaxKind.ContinueStatement: + //return checkBreakOrContinueStatement(node); //case SyntaxKind.CallExpression: //case SyntaxKind.NewExpression: //return checkCallOrNewExpression(node); diff --git a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt index 65fd55b763b..6113009e598 100644 --- a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(8,4): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. ==== tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt index e9643394d12..c89f9c01055 100644 --- a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(8,4): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. ==== tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidForBreakStatements.errors.txt b/tests/baselines/reference/invalidForBreakStatements.errors.txt index 50e4013c0ea..c63c97dcf69 100644 --- a/tests/baselines/reference/invalidForBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForBreakStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(8,9): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. ==== tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidForContinueStatements.errors.txt b/tests/baselines/reference/invalidForContinueStatements.errors.txt index 3af47370df1..459c2c5efa7 100644 --- a/tests/baselines/reference/invalidForContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForContinueStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(8,9): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. ==== tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidForInBreakStatements.errors.txt b/tests/baselines/reference/invalidForInBreakStatements.errors.txt index d83304ab1c6..c12babd3a3a 100644 --- a/tests/baselines/reference/invalidForInBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForInBreakStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(8,19): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. ==== tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidForInContinueStatements.errors.txt b/tests/baselines/reference/invalidForInContinueStatements.errors.txt index 7353a22d9cd..ebd96fd6e46 100644 --- a/tests/baselines/reference/invalidForInContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForInContinueStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(8,19): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. ==== tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt index 54adc2856d7..1ed29772d7b 100644 --- a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(8,14): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. ==== tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt index 462b244efd4..ac658dbc944 100644 --- a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(8,14): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. ==== tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts (6 errors) ==== From bcf73a8207db16ae281cf87b1ec88b8b5a94d5dd Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 15:26:08 -0800 Subject: [PATCH 55/74] Move grammar checking: enumDeclaration; there are still erros from incomplete grammar migration --- src/compiler/checker.ts | 54 +++++++++++++++++++ src/compiler/parser.ts | 2 +- .../reference/ambientErrors.errors.txt | 4 +- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a77da719e52..a259e3a5aa4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8779,6 +8779,9 @@ module ts { } function checkEnumDeclaration(node: EnumDeclaration) { + // Grammar checking + checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + if (!fullTypeCheck) { return; } @@ -10382,6 +10385,57 @@ module ts { } } + function isIntegerLiteral(expression: Expression): boolean { + if (expression.kind === SyntaxKind.PrefixUnaryExpression) { + var unaryExpression = expression; + if (unaryExpression.operator === SyntaxKind.PlusToken || unaryExpression.operator === SyntaxKind.MinusToken) { + expression = unaryExpression.operand; + } + } + if (expression.kind === SyntaxKind.NumericLiteral) { + // Allows for scientific notation since literalExpression.text was formed by + // coercing a number to a string. Sometimes this coercion can yield a string + // in scientific notation. + // We also don't need special logic for hex because a hex integer is converted + // to decimal when it is coerced. + return /^[0-9]+([eE]\+?[0-9]+)?$/.test((expression).text); + } + + return false; + } + + function checkGrammarEnumDeclaration(enumDecl: EnumDeclaration): boolean { + var enumIsConst = (enumDecl.flags & NodeFlags.Const) !== 0; + + var hasError = false; + + // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. + // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. + if (!enumIsConst) { + var inConstantEnumMemberSection = true; + var inAmbientContext = isInAmbientContext(enumDecl); + for (var i = 0, n = enumDecl.members.length; i < n; i++) { + var node = enumDecl.members[i]; + if (node.name.kind === SyntaxKind.ComputedPropertyName) { + hasError = grammarErrorOnNode(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (inAmbientContext) { + if (node.initializer && !isIntegerLiteral(node.initializer)) { + hasError = grammarErrorOnNode(node.name, Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; + } + } + else if (node.initializer) { + inConstantEnumMemberSection = isIntegerLiteral(node.initializer); + } + else if (!inConstantEnumMemberSection) { + hasError = grammarErrorOnNode(node.name, Diagnostics.Enum_member_must_have_initializer) || hasError; + } + } + } + + return hasError; + } + function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b2fbe11fcb5..c823469c7a0 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4633,7 +4633,7 @@ module ts { //case SyntaxKind.NewExpression: //return checkCallOrNewExpression(node); - case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(node); + //case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(node); //case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); //case SyntaxKind.BindingElement: return checkBindingElement(node); //case SyntaxKind.CatchClause: return checkCatchClause(node); diff --git a/tests/baselines/reference/ambientErrors.errors.txt b/tests/baselines/reference/ambientErrors.errors.txt index 6fe7a25dfe9..834c35e541c 100644 --- a/tests/baselines/reference/ambientErrors.errors.txt +++ b/tests/baselines/reference/ambientErrors.errors.txt @@ -1,7 +1,5 @@ tests/cases/conformance/ambient/ambientErrors.ts(2,15): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/conformance/ambient/ambientErrors.ts(24,5): error TS1066: Ambient enum elements can only have integer literal initializers. -tests/cases/conformance/ambient/ambientErrors.ts(29,5): error TS1066: Ambient enum elements can only have integer literal initializers. tests/cases/conformance/ambient/ambientErrors.ts(34,11): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/conformance/ambient/ambientErrors.ts(37,20): error TS1039: Initializers are not allowed in ambient contexts. @@ -11,6 +9,8 @@ tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1037: A functio tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/conformance/ambient/ambientErrors.ts(6,1): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/conformance/ambient/ambientErrors.ts(17,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/ambient/ambientErrors.ts(24,5): error TS1066: Ambient enum elements can only have integer literal initializers. +tests/cases/conformance/ambient/ambientErrors.ts(29,5): error TS1066: Ambient enum elements can only have integer literal initializers. tests/cases/conformance/ambient/ambientErrors.ts(47,20): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/conformance/ambient/ambientErrors.ts(51,16): error TS2436: Ambient external module declaration cannot specify relative module name. tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export assignment cannot be used in a module with other exported elements. From f22adf678534cd2269255ddb1b85e3c9c9ed2b17 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 16:42:31 -0800 Subject: [PATCH 56/74] Move grammar checking: constructorDeclaration; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 32 ++++++++++++-- src/compiler/parser.ts | 6 +-- .../emptyGenericParamList.errors.txt | 8 ++-- ...implicitAnyInAmbientDeclaration.errors.txt | 2 +- ...licitAnyInAmbientDeclaration2.d.errors.txt | 2 +- ...ModuleWithStatementsOfEveryKind.errors.txt | 6 +-- .../parserComputedPropertyName34.errors.txt | 2 +- .../parserConstructorDeclaration12.errors.txt | 42 +++++++++---------- .../reference/protectedMembers.errors.txt | 2 +- .../templateStringInTaggedTemplate.errors.txt | 8 ++-- .../typesWithPrivateConstructor.errors.txt | 2 +- 11 files changed, 68 insertions(+), 44 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a259e3a5aa4..bc202d76371 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7157,8 +7157,7 @@ module ts { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || - node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.ConstructSignature){ + else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || node.kind === SyntaxKind.CallSignature){ checkGrammarFunctionLikeDeclaration(node); } @@ -7241,6 +7240,9 @@ module ts { } function checkConstructorDeclaration(node: ConstructorDeclaration) { + // Grammar check on signature of constructor is done in checkSignatureDeclaration function + checkGrammarModifiers(node) || checkGrammarFunctionLikeDeclaration(node) || checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node) || checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ true); + checkSignatureDeclaration(node); checkSourceElement(node.body); @@ -8244,7 +8246,7 @@ module ts { function checkThrowStatement(node: ThrowStatement) { if (node.expression === undefined) { - grammarErrorAfterFirstToken(getSourceFileOfNode(node), node, Diagnostics.Line_break_not_permitted_here); + grammarErrorAfterFirstToken(node, Diagnostics.Line_break_not_permitted_here); } if (node.expression) { @@ -10481,7 +10483,29 @@ module ts { } } - function grammarErrorAfterFirstToken(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { + function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) { + if (node.typeParameters) { + return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); + } + } + + function checkGrammarConstructorTypeAnnotation(node: ConstructorDeclaration) { + if (node.type) { + return grammarErrorOnNode(node.type, Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); + } + } + + function checkGrammarForBodyInAmbientContext(body: Block | Expression, isConstructor: boolean): boolean { + if (isInAmbientContext(body) && body && body.kind === SyntaxKind.Block) { + var diagnostic = isConstructor + ? Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context + : Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; + return grammarErrorOnFirstToken(body, diagnostic); + } + } + + function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { + var sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text); scanToken(scanner, node.pos); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c823469c7a0..6feeedc159c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4639,7 +4639,7 @@ module ts { //case SyntaxKind.CatchClause: return checkCatchClause(node); //case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); //case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); - case SyntaxKind.Constructor: return checkConstructor(node); + //case SyntaxKind.Constructor: return checkConstructor(node); //case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); //case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); //case SyntaxKind.ExportAssignment: return checkExportAssignment(node); @@ -5323,7 +5323,7 @@ module ts { switch (node.kind) { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: - case SyntaxKind.Constructor: + //case SyntaxKind.Constructor: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: case SyntaxKind.MethodDeclaration: @@ -5331,7 +5331,7 @@ module ts { //case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.ModuleDeclaration: - case SyntaxKind.EnumDeclaration: + //case SyntaxKind.EnumDeclaration: case SyntaxKind.ExportAssignment: case SyntaxKind.VariableStatement: case SyntaxKind.FunctionDeclaration: diff --git a/tests/baselines/reference/emptyGenericParamList.errors.txt b/tests/baselines/reference/emptyGenericParamList.errors.txt index 361e5a2fc21..ed1046d0f49 100644 --- a/tests/baselines/reference/emptyGenericParamList.errors.txt +++ b/tests/baselines/reference/emptyGenericParamList.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/emptyGenericParamList.ts(2,9): error TS1099: Type argument list cannot be empty. tests/cases/compiler/emptyGenericParamList.ts(2,8): error TS2314: Generic type 'I' requires 1 type argument(s). +tests/cases/compiler/emptyGenericParamList.ts(2,9): error TS1099: Type argument list cannot be empty. ==== tests/cases/compiler/emptyGenericParamList.ts (2 errors) ==== class I {} var x: I<>; - ~~ -!!! error TS1099: Type argument list cannot be empty. ~~~ -!!! error TS2314: Generic type 'I' requires 1 type argument(s). \ No newline at end of file +!!! error TS2314: Generic type 'I' requires 1 type argument(s). + ~~ +!!! error TS1099: Type argument list cannot be empty. \ No newline at end of file diff --git a/tests/baselines/reference/implicitAnyInAmbientDeclaration.errors.txt b/tests/baselines/reference/implicitAnyInAmbientDeclaration.errors.txt index 6ec975e33ea..4775ec0511b 100644 --- a/tests/baselines/reference/implicitAnyInAmbientDeclaration.errors.txt +++ b/tests/baselines/reference/implicitAnyInAmbientDeclaration.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(8,9): error TS1089: 'private' modifier cannot appear on a constructor declaration. tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(3,9): error TS7008: Member 'publicMember' implicitly has an 'any' type. tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(6,9): error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type. tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(6,31): error TS7006: Parameter 'x' implicitly has an 'any' type. +tests/cases/compiler/implicitAnyInAmbientDeclaration.ts(8,9): error TS1089: 'private' modifier cannot appear on a constructor declaration. ==== tests/cases/compiler/implicitAnyInAmbientDeclaration.ts (4 errors) ==== diff --git a/tests/baselines/reference/implicitAnyInAmbientDeclaration2.d.errors.txt b/tests/baselines/reference/implicitAnyInAmbientDeclaration2.d.errors.txt index 726c408aced..260dc6c9899 100644 --- a/tests/baselines/reference/implicitAnyInAmbientDeclaration2.d.errors.txt +++ b/tests/baselines/reference/implicitAnyInAmbientDeclaration2.d.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(9,5): error TS1089: 'private' modifier cannot appear on a constructor declaration. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(1,1): error TS7010: 'foo', which lacks return-type annotation, implicitly has an 'any' return type. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(1,22): error TS7006: Parameter 'x' implicitly has an 'any' type. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(2,13): error TS7005: Variable 'bar' implicitly has an 'any' type. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(4,5): error TS7008: Member 'publicMember' implicitly has an 'any' type. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(7,5): error TS7010: 'publicFunction', which lacks return-type annotation, implicitly has an 'any' return type. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(7,27): error TS7006: Parameter 'x' implicitly has an 'any' type. +tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(9,5): error TS1089: 'private' modifier cannot appear on a constructor declaration. tests/cases/compiler/implicitAnyInAmbientDeclaration2.d.ts(13,24): error TS7006: Parameter 'publicConsParam' implicitly has an 'any' type. diff --git a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt index 09647b56771..0d2ef3d6924 100644 --- a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt +++ b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt @@ -1,24 +1,24 @@ tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(13,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(19,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(25,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(38,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(44,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(50,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(64,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(70,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(76,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(4,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(6,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(12,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(15,5): error TS1044: 'public' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(25,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(29,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(31,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(37,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(40,5): error TS1044: 'private' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(50,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(55,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(57,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(63,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(66,5): error TS1044: 'static' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(76,5): error TS1044: 'static' modifier cannot appear on a module element. ==== tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts (21 errors) ==== diff --git a/tests/baselines/reference/parserComputedPropertyName34.errors.txt b/tests/baselines/reference/parserComputedPropertyName34.errors.txt index 05d7375f132..9b244a5a13a 100644 --- a/tests/baselines/reference/parserComputedPropertyName34.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName34.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(3,5): error TS1164: Computed property names are not allowed in enums. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(4,5): error TS1164: Computed property names are not allowed in enums. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(3,11): error TS2304: Cannot find name 'id'. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts(4,5): error TS1164: Computed property names are not allowed in enums. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName34.ts (3 errors) ==== diff --git a/tests/baselines/reference/parserConstructorDeclaration12.errors.txt b/tests/baselines/reference/parserConstructorDeclaration12.errors.txt index 949098e91da..181a3b2215f 100644 --- a/tests/baselines/reference/parserConstructorDeclaration12.errors.txt +++ b/tests/baselines/reference/parserConstructorDeclaration12.errors.txt @@ -1,61 +1,61 @@ -tests/cases/compiler/parserConstructorDeclaration12.ts(2,14): error TS1098: Type parameter list cannot be empty. -tests/cases/compiler/parserConstructorDeclaration12.ts(3,14): error TS1098: Type parameter list cannot be empty. -tests/cases/compiler/parserConstructorDeclaration12.ts(4,15): error TS1098: Type parameter list cannot be empty. -tests/cases/compiler/parserConstructorDeclaration12.ts(5,15): error TS1098: Type parameter list cannot be empty. -tests/cases/compiler/parserConstructorDeclaration12.ts(6,14): error TS1098: Type parameter list cannot be empty. -tests/cases/compiler/parserConstructorDeclaration12.ts(7,14): error TS1098: Type parameter list cannot be empty. -tests/cases/compiler/parserConstructorDeclaration12.ts(8,15): error TS1098: Type parameter list cannot be empty. -tests/cases/compiler/parserConstructorDeclaration12.ts(9,15): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(2,3): error TS2392: Multiple constructor implementations are not allowed. +tests/cases/compiler/parserConstructorDeclaration12.ts(2,14): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(3,3): error TS2392: Multiple constructor implementations are not allowed. +tests/cases/compiler/parserConstructorDeclaration12.ts(3,14): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(4,3): error TS2392: Multiple constructor implementations are not allowed. +tests/cases/compiler/parserConstructorDeclaration12.ts(4,15): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(5,3): error TS2392: Multiple constructor implementations are not allowed. +tests/cases/compiler/parserConstructorDeclaration12.ts(5,15): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(6,3): error TS2392: Multiple constructor implementations are not allowed. +tests/cases/compiler/parserConstructorDeclaration12.ts(6,14): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(7,3): error TS2392: Multiple constructor implementations are not allowed. +tests/cases/compiler/parserConstructorDeclaration12.ts(7,14): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(8,3): error TS2392: Multiple constructor implementations are not allowed. +tests/cases/compiler/parserConstructorDeclaration12.ts(8,15): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(9,3): error TS2392: Multiple constructor implementations are not allowed. +tests/cases/compiler/parserConstructorDeclaration12.ts(9,15): error TS1098: Type parameter list cannot be empty. ==== tests/cases/compiler/parserConstructorDeclaration12.ts (16 errors) ==== class C { constructor<>() { } - ~~ -!!! error TS1098: Type parameter list cannot be empty. ~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - constructor<> () { } ~~ !!! error TS1098: Type parameter list cannot be empty. + constructor<> () { } ~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. + ~~ +!!! error TS1098: Type parameter list cannot be empty. constructor <>() { } - ~~ -!!! error TS1098: Type parameter list cannot be empty. ~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. + ~~ +!!! error TS1098: Type parameter list cannot be empty. constructor <> () { } + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2392: Multiple constructor implementations are not allowed. ~~ !!! error TS1098: Type parameter list cannot be empty. - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2392: Multiple constructor implementations are not allowed. constructor< >() { } - ~~~ -!!! error TS1098: Type parameter list cannot be empty. ~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - constructor< > () { } ~~~ !!! error TS1098: Type parameter list cannot be empty. + constructor< > () { } ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. + ~~~ +!!! error TS1098: Type parameter list cannot be empty. constructor < >() { } - ~~~ -!!! error TS1098: Type parameter list cannot be empty. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - constructor < > () { } ~~~ !!! error TS1098: Type parameter list cannot be empty. + constructor < > () { } ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. + ~~~ +!!! error TS1098: Type parameter list cannot be empty. } \ No newline at end of file diff --git a/tests/baselines/reference/protectedMembers.errors.txt b/tests/baselines/reference/protectedMembers.errors.txt index 10ea00cf10f..c35bc25fe71 100644 --- a/tests/baselines/reference/protectedMembers.errors.txt +++ b/tests/baselines/reference/protectedMembers.errors.txt @@ -1,4 +1,3 @@ -tests/cases/compiler/protectedMembers.ts(86,5): error TS1089: 'protected' modifier cannot appear on a constructor declaration. tests/cases/compiler/protectedMembers.ts(40,1): error TS2445: Property 'x' is protected and only accessible within class 'C1' and its subclasses. tests/cases/compiler/protectedMembers.ts(41,1): error TS2445: Property 'f' is protected and only accessible within class 'C1' and its subclasses. tests/cases/compiler/protectedMembers.ts(42,1): error TS2445: Property 'sx' is protected and only accessible within class 'C1' and its subclasses. @@ -9,6 +8,7 @@ tests/cases/compiler/protectedMembers.ts(48,1): error TS2445: Property 'sx' is p tests/cases/compiler/protectedMembers.ts(49,1): error TS2445: Property 'sf' is protected and only accessible within class 'C2' and its subclasses. tests/cases/compiler/protectedMembers.ts(68,9): error TS2446: Property 'x' is protected and only accessible through an instance of class 'C'. tests/cases/compiler/protectedMembers.ts(69,9): error TS2446: Property 'x' is protected and only accessible through an instance of class 'C'. +tests/cases/compiler/protectedMembers.ts(86,5): error TS1089: 'protected' modifier cannot appear on a constructor declaration. tests/cases/compiler/protectedMembers.ts(98,1): error TS2322: Type 'B1' is not assignable to type 'A1'. Property 'x' is protected but type 'B1' is not a class derived from 'A1'. tests/cases/compiler/protectedMembers.ts(99,1): error TS2322: Type 'A1' is not assignable to type 'B1'. diff --git a/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt b/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt index 45f860bc9a3..9106cdb6151 100644 --- a/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt +++ b/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts(1,42): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts(1,42): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts (2 errors) ==== `I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION` - ~~~~~ -!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + ~~~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/typesWithPrivateConstructor.errors.txt b/tests/baselines/reference/typesWithPrivateConstructor.errors.txt index 010831effe8..2440e51cd39 100644 --- a/tests/baselines/reference/typesWithPrivateConstructor.errors.txt +++ b/tests/baselines/reference/typesWithPrivateConstructor.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(4,5): error TS1089: 'private' modifier cannot appear on a constructor declaration. +tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(8,5): error TS2322: Type 'Function' is not assignable to type '() => void'. tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(11,5): error TS1089: 'private' modifier cannot appear on a constructor declaration. tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(12,5): error TS1089: 'private' modifier cannot appear on a constructor declaration. -tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(8,5): error TS2322: Type 'Function' is not assignable to type '() => void'. tests/cases/conformance/types/members/typesWithPrivateConstructor.ts(15,10): error TS2346: Supplied parameters do not match any signature of call target. From 90333fe49b389b085813fe79b320aa57f760adc8 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 16:43:35 -0800 Subject: [PATCH 57/74] Address code review --- src/compiler/checker.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bc202d76371..746061c008a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8173,14 +8173,11 @@ module ts { function checkWithStatement(node: WithStatement) { // Grammar checking for withStatement - var hasStrictModeError = false; if (node.parserContextFlags & ParserContextFlags.StrictMode) { grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); - hasStrictModeError = true; } - - // Grammar checking for invalid use of return statement - if (!hasStrictModeError) { + else { + // Grammar checking for invalid use of return statement forEachReturnStatement(node.statement, (returnStatement) => { grammarErrorOnFirstToken(returnStatement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); }); From 5cb958ef43c4b3c1a8d2d474b8fa858b5111610b Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 17:16:22 -0800 Subject: [PATCH 58/74] Address code review --- src/compiler/checker.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 746061c008a..349f3766be6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7157,7 +7157,8 @@ module ts { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || node.kind === SyntaxKind.CallSignature){ + else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || + node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.Constructor){ checkGrammarFunctionLikeDeclaration(node); } @@ -7240,10 +7241,11 @@ module ts { } function checkConstructorDeclaration(node: ConstructorDeclaration) { - // Grammar check on signature of constructor is done in checkSignatureDeclaration function - checkGrammarModifiers(node) || checkGrammarFunctionLikeDeclaration(node) || checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node) || checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ true); - + // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. checkSignatureDeclaration(node); + // Grammar check for checking only related to constructoDeclaration + checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node) || checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ true); + checkSourceElement(node.body); var symbol = getSymbolOfNode(node); @@ -8178,7 +8180,7 @@ module ts { } else { // Grammar checking for invalid use of return statement - forEachReturnStatement(node.statement, (returnStatement) => { + forEachReturnStatement(node.statement, returnStatement => { grammarErrorOnFirstToken(returnStatement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); }); } From 20b7bb249ef366bc9d759883432e8c89739e3d05 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 17:23:33 -0800 Subject: [PATCH 59/74] Address code review --- src/compiler/checker.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 746061c008a..154908778a9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7157,7 +7157,9 @@ module ts { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || node.kind === SyntaxKind.CallSignature){ + else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || + node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.Constructor || + node.kind === SyntaxKind.ConstructSignature){ checkGrammarFunctionLikeDeclaration(node); } @@ -7240,10 +7242,11 @@ module ts { } function checkConstructorDeclaration(node: ConstructorDeclaration) { - // Grammar check on signature of constructor is done in checkSignatureDeclaration function - checkGrammarModifiers(node) || checkGrammarFunctionLikeDeclaration(node) || checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node) || checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ true); - + // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. checkSignatureDeclaration(node); + // Grammar check for checking only related to constructoDeclaration + checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node) || checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ true); + checkSourceElement(node.body); var symbol = getSymbolOfNode(node); @@ -8178,7 +8181,7 @@ module ts { } else { // Grammar checking for invalid use of return statement - forEachReturnStatement(node.statement, (returnStatement) => { + forEachReturnStatement(node.statement, returnStatement => { grammarErrorOnFirstToken(returnStatement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); }); } From e0e88adfc51d8b5ddad783adcdeabd8e4b642b51 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 18:10:35 -0800 Subject: [PATCH 60/74] Move grammar checking: variableDeclaration, variableStatements; there are still erros from incomplete grammar migration --- src/compiler/checker.ts | 89 +++++++++++++++++-- src/compiler/parser.ts | 6 +- .../initializersInDeclarations.errors.txt | 2 +- .../invalidModuleWithVarStatements.errors.txt | 6 +- .../reference/letDeclarations-es5.errors.txt | 4 +- tests/baselines/reference/varBlock.errors.txt | 12 +-- ...ariableDeclarationInStrictMode1.errors.txt | 2 +- 7 files changed, 97 insertions(+), 24 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 154908778a9..a58b8f052aa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8000,7 +8000,10 @@ module ts { // Grammar checking // TODO (yuisu) : Revisit this check once move all grammar checking if (node.kind === SyntaxKind.BindingElement) { - checkGrammarBindingElement(node); + checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + } + else if (node.kind === SyntaxKind.VariableDeclaration) { + checkGrammarVariableDeclaration(node); } checkSourceElement(node.type); @@ -8059,6 +8062,9 @@ module ts { } function checkVariableStatement(node: VariableStatement) { + // Grammar checking + checkGrammarModifiers(node) || checkGrammarVariableDeclarations(node, node.declarations) || checkGrammarForDisallowedLetOrConstStatement(node); + forEach(node.declarations, checkSourceElement); } @@ -8091,7 +8097,6 @@ module ts { } function checkForInStatement(node: ForInStatement) { - // TypeScript 1.0 spec (April 2014): 5.4 // In a 'for-in' statement of the form // for (var VarDecl in Expr) Statement @@ -10132,12 +10137,6 @@ module ts { checkGrammarForOmittedArgument(node, arguments); } - function checkGrammarBindingElement(node: BindingElement) { - // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code - // and its Identifier is eval or arguments - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); - } - function checkGrammarHeritageClause(node: HeritageClause): boolean { var types = node.types; if (checkGrammarForDisallowedTrailingComma(types)) { @@ -10387,6 +10386,80 @@ module ts { } } + function checkGrammarVariableDeclaration(node: VariableDeclaration) { + if (isInAmbientContext(node)) { + if (isBindingPattern(node.name)) { + return grammarErrorOnNode(node, Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts); + } + if (node.initializer) { + // Error on equals token which immediate precedes the initializer + return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - 1, 1, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + else { + if (!node.initializer) { + if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { + return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); + } + if (isConst(node)) { + return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); + } + } + } + // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code + // and its Identifier is eval or arguments + return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); + } + + function checkGrammarVariableDeclarations(variableStatement: VariableStatement, declarations: NodeArray): boolean { + if (declarations) { + if (checkGrammarForDisallowedTrailingComma(declarations)) { + return true; + } + + if (!declarations.length) { + return grammarErrorAtPos(getSourceFileOfNode(variableStatement), declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty); + } + + var decl = declarations[0]; + if (compilerOptions.target < ScriptTarget.ES6) { + if (isLet(decl)) { + return grammarErrorOnFirstToken(decl, Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + else if (isConst(decl)) { + return grammarErrorOnFirstToken(decl, Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + } + } + } + + function allowLetAndConstDeclarations(parent: Node): boolean { + switch (parent.kind) { + case SyntaxKind.IfStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + case SyntaxKind.WithStatement: + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + return false; + case SyntaxKind.LabeledStatement: + return allowLetAndConstDeclarations(parent.parent); + } + + return true; + } + + function checkGrammarForDisallowedLetOrConstStatement(node: VariableStatement) { + if (!allowLetAndConstDeclarations(node.parent)) { + if (isLet(node)) { + return grammarErrorOnNode(node, Diagnostics.let_declarations_can_only_be_declared_inside_a_block); + } + else if (isConst(node)) { + return grammarErrorOnNode(node, Diagnostics.const_declarations_can_only_be_declared_inside_a_block); + } + } + } + function isIntegerLiteral(expression: Expression): boolean { if (expression.kind === SyntaxKind.PrefixUnaryExpression) { var unaryExpression = expression; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6feeedc159c..7f73c275327 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4673,8 +4673,8 @@ module ts { //case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); //case SyntaxKind.ThrowStatement: return checkThrowStatement(node); //case SyntaxKind.TypeReference: return checkTypeReference(node); - case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); - case SyntaxKind.VariableStatement: return checkVariableStatement(node); + //case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); + //case SyntaxKind.VariableStatement: return checkVariableStatement(node); //case SyntaxKind.WithStatement: return checkWithStatement(node); //case SyntaxKind.YieldExpression: return checkYieldExpression(node); } @@ -5333,7 +5333,7 @@ module ts { case SyntaxKind.ModuleDeclaration: //case SyntaxKind.EnumDeclaration: case SyntaxKind.ExportAssignment: - case SyntaxKind.VariableStatement: + //case SyntaxKind.VariableStatement: case SyntaxKind.FunctionDeclaration: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.ImportDeclaration: diff --git a/tests/baselines/reference/initializersInDeclarations.errors.txt b/tests/baselines/reference/initializersInDeclarations.errors.txt index 5ab9ae5d2bc..ad92cc79281 100644 --- a/tests/baselines/reference/initializersInDeclarations.errors.txt +++ b/tests/baselines/reference/initializersInDeclarations.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/externalModules/initializersInDeclarations.ts(5,9): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(6,16): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(7,16): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/conformance/externalModules/initializersInDeclarations.ts(16,2): error TS1036: Statements are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(12,15): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(13,15): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/conformance/externalModules/initializersInDeclarations.ts(16,2): error TS1036: Statements are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(18,16): error TS1039: Initializers are not allowed in ambient contexts. diff --git a/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt b/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt index ad8d457670a..e0ba35c3385 100644 --- a/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt +++ b/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(4,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(8,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(12,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(16,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(20,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(25,5): error TS1044: 'private' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(4,5): error TS1044: 'public' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(12,5): error TS1044: 'static' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(20,5): error TS1044: 'private' modifier cannot appear on a module element. ==== tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/letDeclarations-es5.errors.txt b/tests/baselines/reference/letDeclarations-es5.errors.txt index 34bd93dba3c..19551e9fad5 100644 --- a/tests/baselines/reference/letDeclarations-es5.errors.txt +++ b/tests/baselines/reference/letDeclarations-es5.errors.txt @@ -1,11 +1,11 @@ +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(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(4,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(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(12,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. ==== tests/cases/compiler/letDeclarations-es5.ts (8 errors) ==== diff --git a/tests/baselines/reference/varBlock.errors.txt b/tests/baselines/reference/varBlock.errors.txt index 0d9b5f6b1b4..6746a760a44 100644 --- a/tests/baselines/reference/varBlock.errors.txt +++ b/tests/baselines/reference/varBlock.errors.txt @@ -1,4 +1,6 @@ tests/cases/compiler/varBlock.ts(8,16): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/compiler/varBlock.ts(11,22): error TS2369: A parameter property is only allowed in a constructor implementation. +tests/cases/compiler/varBlock.ts(11,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/compiler/varBlock.ts(15,15): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/varBlock.ts(21,16): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/varBlock.ts(22,20): error TS1039: Initializers are not allowed in ambient contexts. @@ -14,10 +16,8 @@ tests/cases/compiler/varBlock.ts(33,25): error TS1039: Initializers are not allo tests/cases/compiler/varBlock.ts(34,19): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/varBlock.ts(35,25): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/compiler/varBlock.ts(35,35): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(39,15): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/compiler/varBlock.ts(11,22): error TS2369: A parameter property is only allowed in a constructor implementation. -tests/cases/compiler/varBlock.ts(11,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/compiler/varBlock.ts(39,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'any', but here has type 'number'. +tests/cases/compiler/varBlock.ts(39,15): error TS1039: Initializers are not allowed in ambient contexts. ==== tests/cases/compiler/varBlock.ts (20 errors) ==== @@ -96,7 +96,7 @@ tests/cases/compiler/varBlock.ts(39,13): error TS2403: Subsequent variable decla declare var c; declare var c = 10; - ~ -!!! error TS1039: Initializers are not allowed in ambient contexts. ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'any', but here has type 'number'. \ No newline at end of file +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'any', but here has type 'number'. + ~ +!!! error TS1039: Initializers are not allowed in ambient contexts. \ No newline at end of file diff --git a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt index aa2ccdbed9f..328e080fbaa 100644 --- a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt +++ b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS1100: Invalid use of 'eval' in strict mode. lib.d.ts(29,18): error TS2300: Duplicate identifier 'eval'. +tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS2300: Duplicate identifier 'eval'. From 010745c3713b37c5f53d7740390fdc408785a676 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 18:28:24 -0800 Subject: [PATCH 61/74] Move grammar checking: forInStatement; there are still errors from incomplete migration --- src/compiler/checker.ts | 12 ++++++++++-- src/compiler/parser.ts | 2 +- .../reference/constDeclarations-errors.errors.txt | 2 +- .../reference/declareAlreadySeen.errors.txt | 2 +- .../reference/letDeclarations-es5.errors.txt | 2 +- .../reference/parserForInStatement7.errors.txt | 6 +++--- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a58b8f052aa..527e1bdb1a7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8097,6 +8097,14 @@ module ts { } 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 // In a 'for-in' statement of the form // for (var VarDecl in Expr) Statement @@ -10411,14 +10419,14 @@ module ts { return checkGrammarEvalOrArgumentsInStrictMode(node, node.name); } - function checkGrammarVariableDeclarations(variableStatement: VariableStatement, declarations: NodeArray): boolean { + function checkGrammarVariableDeclarations(container: Node, declarations: NodeArray): boolean { if (declarations) { if (checkGrammarForDisallowedTrailingComma(declarations)) { return true; } 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]; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7f73c275327..7e3aff21915 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4644,7 +4644,7 @@ module ts { //case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); //case SyntaxKind.ExportAssignment: return checkExportAssignment(node); //case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); - case SyntaxKind.ForInStatement: return checkForInStatement(node); + //case SyntaxKind.ForInStatement: return checkForInStatement(node); case SyntaxKind.ForStatement: return checkForStatement(node); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); //case SyntaxKind.FunctionExpression: return checkFunctionExpression(node); diff --git a/tests/baselines/reference/constDeclarations-errors.errors.txt b/tests/baselines/reference/constDeclarations-errors.errors.txt index d87007474a1..c0ae6635c5e 100644 --- a/tests/baselines/reference/constDeclarations-errors.errors.txt +++ b/tests/baselines/reference/constDeclarations-errors.errors.txt @@ -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,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(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(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) ==== diff --git a/tests/baselines/reference/declareAlreadySeen.errors.txt b/tests/baselines/reference/declareAlreadySeen.errors.txt index d606b571478..60cd204c40c 100644 --- a/tests/baselines/reference/declareAlreadySeen.errors.txt +++ b/tests/baselines/reference/declareAlreadySeen.errors.txt @@ -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(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. diff --git a/tests/baselines/reference/letDeclarations-es5.errors.txt b/tests/baselines/reference/letDeclarations-es5.errors.txt index 19551e9fad5..824e36e2791 100644 --- a/tests/baselines/reference/letDeclarations-es5.errors.txt +++ b/tests/baselines/reference/letDeclarations-es5.errors.txt @@ -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(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. @@ -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(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(10,9): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. ==== tests/cases/compiler/letDeclarations-es5.ts (8 errors) ==== diff --git a/tests/baselines/reference/parserForInStatement7.errors.txt b/tests/baselines/reference/parserForInStatement7.errors.txt index 2371b3453c3..397401003db 100644 --- a/tests/baselines/reference/parserForInStatement7.errors.txt +++ b/tests/baselines/reference/parserForInStatement7.errors.txt @@ -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,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 (3 errors) ==== 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 TS1091: Only a single variable declaration is allowed in a 'for...in' statement. ~ !!! error TS2304: Cannot find name 'X'. } \ No newline at end of file From 25a6302b48a9b12e2f48555e71ba4c10623d7524 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 18:39:44 -0800 Subject: [PATCH 62/74] Move grammar checking: forStatement --- src/compiler/checker.ts | 3 +++ src/compiler/parser.ts | 2 +- tests/baselines/reference/letDeclarations-es5.errors.txt | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 527e1bdb1a7..a7805255a96 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8089,6 +8089,9 @@ module ts { } function checkForStatement(node: ForStatement) { + // Grammar checking + checkGrammarVariableDeclarations(node, node.declarations); + if (node.declarations) forEach(node.declarations, checkVariableLikeDeclaration); if (node.initializer) checkExpression(node.initializer); if (node.condition) checkExpression(node.condition); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7e3aff21915..6b8df5cdad5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4645,7 +4645,7 @@ module ts { //case SyntaxKind.ExportAssignment: return checkExportAssignment(node); //case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); //case SyntaxKind.ForInStatement: return checkForInStatement(node); - case SyntaxKind.ForStatement: return checkForStatement(node); + //case SyntaxKind.ForStatement: return checkForStatement(node); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); //case SyntaxKind.FunctionExpression: return checkFunctionExpression(node); case SyntaxKind.GetAccessor: return checkGetAccessor(node); diff --git a/tests/baselines/reference/letDeclarations-es5.errors.txt b/tests/baselines/reference/letDeclarations-es5.errors.txt index 824e36e2791..34bd93dba3c 100644 --- a/tests/baselines/reference/letDeclarations-es5.errors.txt +++ b/tests/baselines/reference/letDeclarations-es5.errors.txt @@ -1,4 +1,3 @@ -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(3,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. tests/cases/compiler/letDeclarations-es5.ts(4,5): error TS1153: 'let' declarations are only available when targeting ECMAScript 6 and higher. @@ -6,6 +5,7 @@ tests/cases/compiler/letDeclarations-es5.ts(6,5): error TS1153: 'let' declaratio 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(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 (8 errors) ==== From 694771b2d791868b7735225fc7565ada1e115b23 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 15 Dec 2014 23:05:29 -0800 Subject: [PATCH 63/74] Move grammar checking: functionDeclaration; there are still errors from incomplet grammar migration --- src/compiler/checker.ts | 6 +++++- src/compiler/parser.ts | 4 ++-- tests/baselines/reference/declareAlreadySeen.errors.txt | 2 +- .../reference/invalidModuleWithVarStatements.errors.txt | 6 +++--- .../reference/optionalArgsWithDefaultValues.errors.txt | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a7805255a96..fa7b6f571ef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7157,7 +7157,7 @@ module ts { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.ConstructorType || + else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.ConstructorType || node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.Constructor || node.kind === SyntaxKind.ConstructSignature){ checkGrammarFunctionLikeDeclaration(node); @@ -7764,7 +7764,11 @@ module ts { } function checkFunctionDeclaration(node: FunctionDeclaration): void { + // Grammar Checking, check signature of function declaration as checkFunctionLikeDeclaration call checkGarmmarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); + //Grammar check other component of the functionDeclaration + checkGrammarFunctionName(node.name) || checkGrammarForBodyInAmbientContext(node.body, /*isConstructor*/ false) || checkGrammarForGenerator(node); + if (fullTypeCheck) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6b8df5cdad5..99d1cb69f10 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4646,7 +4646,7 @@ module ts { //case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); //case SyntaxKind.ForInStatement: return checkForInStatement(node); //case SyntaxKind.ForStatement: return checkForStatement(node); - case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); + //case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); //case SyntaxKind.FunctionExpression: return checkFunctionExpression(node); case SyntaxKind.GetAccessor: return checkGetAccessor(node); //case SyntaxKind.HeritageClause: return checkHeritageClause(node); @@ -5334,7 +5334,7 @@ module ts { //case SyntaxKind.EnumDeclaration: case SyntaxKind.ExportAssignment: //case SyntaxKind.VariableStatement: - case SyntaxKind.FunctionDeclaration: + //case SyntaxKind.FunctionDeclaration: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.ImportDeclaration: //case SyntaxKind.Parameter: diff --git a/tests/baselines/reference/declareAlreadySeen.errors.txt b/tests/baselines/reference/declareAlreadySeen.errors.txt index 60cd204c40c..da671ad313a 100644 --- a/tests/baselines/reference/declareAlreadySeen.errors.txt +++ b/tests/baselines/reference/declareAlreadySeen.errors.txt @@ -1,6 +1,6 @@ -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(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(7,13): error TS1030: 'declare' modifier already seen. diff --git a/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt b/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt index e0ba35c3385..ad8d457670a 100644 --- a/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt +++ b/tests/baselines/reference/invalidModuleWithVarStatements.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(8,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(16,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(25,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(4,5): error TS1044: 'public' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(8,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(12,5): error TS1044: 'static' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(16,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(20,5): error TS1044: 'private' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts(25,5): error TS1044: 'private' modifier cannot appear on a module element. ==== tests/cases/conformance/internalModules/moduleBody/invalidModuleWithVarStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/optionalArgsWithDefaultValues.errors.txt b/tests/baselines/reference/optionalArgsWithDefaultValues.errors.txt index 414e718ac71..784f8b64e2a 100644 --- a/tests/baselines/reference/optionalArgsWithDefaultValues.errors.txt +++ b/tests/baselines/reference/optionalArgsWithDefaultValues.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/optionalArgsWithDefaultValues.ts(1,25): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/optionalArgsWithDefaultValues.ts(4,27): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/optionalArgsWithDefaultValues.ts(5,28): error TS1015: Parameter cannot have question mark and initializer. +tests/cases/compiler/optionalArgsWithDefaultValues.ts(1,25): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/optionalArgsWithDefaultValues.ts(8,10): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/optionalArgsWithDefaultValues.ts(9,13): error TS1015: Parameter cannot have question mark and initializer. From 7a4d8cd8ee711fc47d81c9c4fc45a50544535431 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 16 Dec 2014 12:25:05 -0800 Subject: [PATCH 64/74] Move grammar checking: setAccessor, getAccessor; there are still erros from incomplete grammar migration --- src/compiler/checker.ts | 47 ++++++++++++++++++- .../diagnosticInformationMap.generated.ts | 12 ++--- src/compiler/diagnosticMessages.json | 18 ++++--- src/compiler/parser.ts | 8 ++-- .../accessibilityModifiers.errors.txt | 12 ++--- ...rParameterAccessibilityModifier.errors.txt | 2 +- .../accessorParameterAccessibilityModifier.js | 25 ++++++++++ ...rs_spec_section-4.5_error-cases.errors.txt | 8 ++-- .../reference/anyIdenticalToItself.errors.txt | 2 +- ...uperAndLocalFunctionInAccessors.errors.txt | 6 +-- ...sionSuperAndLocalVarInAccessors.errors.txt | 6 +-- .../collisionSuperAndParameter.errors.txt | 2 +- ...xpressionAndLocalVarInAccessors.errors.txt | 6 +-- ...InstanceShadowingPublicInstance.errors.txt | 4 +- ...vateStaticShadowingPublicStatic.errors.txt | 4 +- .../duplicateClassElements.errors.txt | 20 ++++---- .../errorSuperPropertyAccess.errors.txt | 16 +++---- .../errorsInGenericTypeReference.errors.txt | 2 +- .../reference/es6ClassTest2.errors.txt | 2 +- .../fieldAndGetterWithSameName.errors.txt | 2 +- ...functionAndPropertyNameConflict.errors.txt | 2 +- .../genericReturnTypeFromGetter1.errors.txt | 2 +- ...ReturnTypeAndFunctionClassMerge.errors.txt | 2 +- .../getAndSetNotIdenticalType.errors.txt | 10 ++-- .../getAndSetNotIdenticalType2.errors.txt | 8 ++-- .../getAndSetNotIdenticalType3.errors.txt | 8 ++-- .../reference/gettersAndSetters.errors.txt | 4 +- .../gettersAndSettersAccessibility.errors.txt | 2 +- .../gettersAndSettersErrors.errors.txt | 8 ++-- .../illegalSuperCallsInConstructor.errors.txt | 8 ++-- .../implicitAnyCastedValue.errors.txt | 6 +-- ...AndSetAccessorWithAnyReturnType.errors.txt | 10 ++-- .../reference/inferSetterParamType.errors.txt | 2 +- ...eMemberAccessorOverridingMethod.errors.txt | 4 +- ...eStaticAccessorOverridingMethod.errors.txt | 4 +- ...ropertiesInheritedIntoClassType.errors.txt | 2 +- .../instancePropertyInClassType.errors.txt | 2 +- ...rConstrainsPropertyDeclarations.errors.txt | 8 ++-- .../objectLiteralGettersAndSetters.errors.txt | 4 +- .../reference/parserAstSpans1.errors.txt | 2 +- .../parserMemberAccessorDeclaration15.js | 17 +++++++ ...propertyAndAccessorWithSameName.errors.txt | 8 ++-- .../staticPropertyNotInClassType.errors.txt | 4 +- .../reference/staticVisibility.errors.txt | 4 +- ...rConstrainsPropertyDeclarations.errors.txt | 10 ++-- .../reference/superPropertyAccess1.errors.txt | 2 +- .../reference/superPropertyAccess2.errors.txt | 2 +- ...ect-literal-getters-and-setters.errors.txt | 4 +- .../twoAccessorsWithSameName2.errors.txt | 8 ++-- .../typeOfThisInInstanceMember.errors.txt | 2 +- ...typeParametersInStaticAccessors.errors.txt | 2 +- 51 files changed, 229 insertions(+), 136 deletions(-) create mode 100644 tests/baselines/reference/accessorParameterAccessibilityModifier.js create mode 100644 tests/baselines/reference/parserMemberAccessorDeclaration15.js diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fa7b6f571ef..6cb38e98eaa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7329,7 +7329,10 @@ module ts { } function checkAccessorDeclaration(node: AccessorDeclaration) { - // Grammar checking + // Grammar checking accessors + checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node); + + // Grammar checking if name is a computed-property if (node.name.kind === SyntaxKind.ComputedPropertyName) { checkGrammarComputedPropertyName(node.name); } @@ -10333,6 +10336,48 @@ module ts { } } + function checkGrammarAccessor(accessor: MethodDeclaration): boolean { + var kind = accessor.kind; + if (compilerOptions.target < ScriptTarget.ES5) { + return grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + else if (isInAmbientContext(accessor)) { + return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); + } + else if (accessor.body === undefined) { + return grammarErrorAtPos(getSourceFileOfNode(accessor), accessor.end - 1, ";".length, Diagnostics._0_expected, "{"); + } + else if (accessor.typeParameters) { + return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_have_type_parameters); + } + else if (kind === SyntaxKind.GetAccessor && accessor.parameters.length) { + return grammarErrorOnNode(accessor.name, Diagnostics.A_get_accessor_cannot_have_parameters); + } + else if (kind === SyntaxKind.SetAccessor) { + if (accessor.type) { + return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); + } + else if (accessor.parameters.length !== 1) { + return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_must_have_exactly_one_parameter); + } + else { + var parameter = accessor.parameters[0]; + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + else if (parameter.flags & NodeFlags.Modifier) { + return grammarErrorOnNode(accessor.name, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); + } + else if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + else if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); + } + } + } + } + function isIterationStatement(node: Node, lookInLabeledStatements: boolean): boolean { switch (node.kind) { case SyntaxKind.ForStatement: diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index fa21ddd03d4..085fb5c9654 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -4,7 +4,7 @@ module ts { export var Diagnostics = { Unterminated_string_literal: { code: 1002, category: DiagnosticCategory.Error, key: "Unterminated string literal." }, Identifier_expected: { code: 1003, category: DiagnosticCategory.Error, key: "Identifier expected." }, - _0_expected: { code: 1005, category: DiagnosticCategory.Error, key: "'{0}' expected." }, + _0_expected: { code: 1005, category: DiagnosticCategory.Error, key: "'{0}' expected.", isEarly: true }, A_file_cannot_have_a_reference_to_itself: { code: 1006, category: DiagnosticCategory.Error, key: "A file cannot have a reference to itself." }, Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed.", isEarly: true }, Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." }, @@ -40,9 +40,9 @@ module ts { A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional.", isEarly: true }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, - A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, - A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, - A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, + A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter.", isEarly: true }, + A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter.", isEarly: true }, + A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer.", isEarly: true }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter.", isEarly: true }, A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters.", isEarly: true }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher.", isEarly: true }, @@ -59,8 +59,8 @@ module ts { Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement.", isEarly: true }, Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration.", isEarly: true }, Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration.", isEarly: true }, - An_accessor_cannot_have_type_parameters: { code: 1094, category: DiagnosticCategory.Error, key: "An accessor cannot have type parameters." }, - A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." }, + An_accessor_cannot_have_type_parameters: { code: 1094, category: DiagnosticCategory.Error, key: "An accessor cannot have type parameters.", isEarly: true }, + A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation.", isEarly: true }, An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: DiagnosticCategory.Error, key: "An index signature must have exactly one parameter.", isEarly: true }, _0_list_cannot_be_empty: { code: 1097, category: DiagnosticCategory.Error, key: "'{0}' list cannot be empty.", isEarly: true }, Type_parameter_list_cannot_be_empty: { code: 1098, category: DiagnosticCategory.Error, key: "Type parameter list cannot be empty.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3ddd6cf2a84..5d8f79eac42 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -9,7 +9,8 @@ }, "'{0}' expected.": { "category": "Error", - "code": 1005 + "code": 1005, + "isEarly": true }, "A file cannot have a reference to itself.": { "category": "Error", @@ -176,15 +177,18 @@ }, "A 'set' accessor must have exactly one parameter.": { "category": "Error", - "code": 1049 + "code": 1049, + "isEarly": true }, "A 'set' accessor cannot have an optional parameter.": { "category": "Error", - "code": 1051 + "code": 1051, + "isEarly": true }, "A 'set' accessor parameter cannot have an initializer.": { "category": "Error", - "code": 1052 + "code": 1052, + "isEarly": true }, "A 'set' accessor cannot have rest parameter.": { "category": "Error", @@ -265,11 +269,13 @@ }, "An accessor cannot have type parameters.": { "category": "Error", - "code": 1094 + "code": 1094, + "isEarly": true }, "A 'set' accessor cannot have a return type annotation.": { "category": "Error", - "code": 1095 + "code": 1095, + "isEarly": true }, "An index signature must have exactly one parameter.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 99d1cb69f10..24f0dafaa27 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4648,7 +4648,7 @@ module ts { //case SyntaxKind.ForStatement: return checkForStatement(node); //case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); //case SyntaxKind.FunctionExpression: return checkFunctionExpression(node); - case SyntaxKind.GetAccessor: return checkGetAccessor(node); + //case SyntaxKind.GetAccessor: return checkGetAccessor(node); //case SyntaxKind.HeritageClause: return checkHeritageClause(node); //case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node); //case SyntaxKind.LabeledStatement: return checkLabeledStatement(node); @@ -4666,7 +4666,7 @@ module ts { case SyntaxKind.PropertySignature: return checkProperty(node); //case SyntaxKind.ReturnStatement: return checkReturnStatement(node); - case SyntaxKind.SetAccessor: return checkSetAccessor(node); + //case SyntaxKind.SetAccessor: return checkSetAccessor(node); case SyntaxKind.SourceFile: return checkSourceFile(node); //case SyntaxKind.ShorthandPropertyAssignment: return checkShorthandPropertyAssignment(node); //case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); @@ -5321,8 +5321,8 @@ module ts { function checkModifiers(node: Node): boolean { switch (node.kind) { - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: + //case SyntaxKind.GetAccessor: + //case SyntaxKind.SetAccessor: //case SyntaxKind.Constructor: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: diff --git a/tests/baselines/reference/accessibilityModifiers.errors.txt b/tests/baselines/reference/accessibilityModifiers.errors.txt index 1bf92139761..f571c8e3ee0 100644 --- a/tests/baselines/reference/accessibilityModifiers.errors.txt +++ b/tests/baselines/reference/accessibilityModifiers.errors.txt @@ -1,17 +1,17 @@ tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(22,12): error TS1029: 'private' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(23,12): error TS1029: 'private' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(24,12): error TS1029: 'private' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(25,12): error TS1029: 'private' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(27,12): error TS1029: 'protected' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(28,12): error TS1029: 'protected' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(29,12): error TS1029: 'protected' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(30,12): error TS1029: 'protected' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(32,12): error TS1029: 'public' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(33,12): error TS1029: 'public' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(34,12): error TS1029: 'public' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(35,12): error TS1029: 'public' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(40,13): error TS1028: Accessibility modifier already seen. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(41,12): error TS1028: Accessibility modifier already seen. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(24,12): error TS1029: 'private' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(25,12): error TS1029: 'private' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(29,12): error TS1029: 'protected' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(30,12): error TS1029: 'protected' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(34,12): error TS1029: 'public' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(35,12): error TS1029: 'public' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(42,13): error TS1028: Accessibility modifier already seen. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(43,12): error TS1028: Accessibility modifier already seen. diff --git a/tests/baselines/reference/accessorParameterAccessibilityModifier.errors.txt b/tests/baselines/reference/accessorParameterAccessibilityModifier.errors.txt index 401a0107d89..fad1d8ff10a 100644 --- a/tests/baselines/reference/accessorParameterAccessibilityModifier.errors.txt +++ b/tests/baselines/reference/accessorParameterAccessibilityModifier.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/accessorParameterAccessibilityModifier.ts(3,9): error TS2369: A parameter property is only allowed in a constructor implementation. -tests/cases/compiler/accessorParameterAccessibilityModifier.ts(4,16): error TS2369: A parameter property is only allowed in a constructor implementation. tests/cases/compiler/accessorParameterAccessibilityModifier.ts(3,11): error TS2369: A parameter property is only allowed in a constructor implementation. +tests/cases/compiler/accessorParameterAccessibilityModifier.ts(4,16): error TS2369: A parameter property is only allowed in a constructor implementation. tests/cases/compiler/accessorParameterAccessibilityModifier.ts(4,18): error TS2369: A parameter property is only allowed in a constructor implementation. diff --git a/tests/baselines/reference/accessorParameterAccessibilityModifier.js b/tests/baselines/reference/accessorParameterAccessibilityModifier.js new file mode 100644 index 00000000000..89a511e6c5c --- /dev/null +++ b/tests/baselines/reference/accessorParameterAccessibilityModifier.js @@ -0,0 +1,25 @@ +//// [accessorParameterAccessibilityModifier.ts] + +class C { + set X(public v) { } + static set X(public v2) { } +} + +//// [accessorParameterAccessibilityModifier.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "X", { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "X", { + set: function (v2) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt index 22fdeb099bc..981cb525625 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt +++ b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt @@ -1,15 +1,15 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,55): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,54): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,55): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,54): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,52): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,51): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts (12 errors) ==== diff --git a/tests/baselines/reference/anyIdenticalToItself.errors.txt b/tests/baselines/reference/anyIdenticalToItself.errors.txt index ea8583a6a75..6b82f3af73c 100644 --- a/tests/baselines/reference/anyIdenticalToItself.errors.txt +++ b/tests/baselines/reference/anyIdenticalToItself.errors.txt @@ -1,6 +1,6 @@ +tests/cases/compiler/anyIdenticalToItself.ts(1,1): error TS2394: Overload signature is not compatible with function implementation. tests/cases/compiler/anyIdenticalToItself.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/anyIdenticalToItself.ts(10,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/anyIdenticalToItself.ts(1,1): error TS2394: Overload signature is not compatible with function implementation. ==== tests/cases/compiler/anyIdenticalToItself.ts (3 errors) ==== diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.errors.txt b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.errors.txt index 15ad1e0e8e7..6a459b222c7 100644 --- a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.errors.txt +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.errors.txt @@ -1,12 +1,12 @@ tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(4,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(9,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(20,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(33,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(16,9): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. +tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(20,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(21,9): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. +tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(28,13): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. +tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(33,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalFunctionInAccessors.ts(35,13): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.errors.txt b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.errors.txt index 47c52c2582e..7e0f80f0658 100644 --- a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.errors.txt +++ b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.errors.txt @@ -1,12 +1,12 @@ tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(7,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(16,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(21,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(27,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(13,13): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. +tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(16,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(17,13): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. +tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(21,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(23,17): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. +tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(27,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndLocalVarInAccessors.ts(29,17): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. diff --git a/tests/baselines/reference/collisionSuperAndParameter.errors.txt b/tests/baselines/reference/collisionSuperAndParameter.errors.txt index b3dcdbf1be8..65dddd95d48 100644 --- a/tests/baselines/reference/collisionSuperAndParameter.errors.txt +++ b/tests/baselines/reference/collisionSuperAndParameter.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/collisionSuperAndParameter.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/collisionSuperAndParameter.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndParameter.ts(17,22): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. tests/cases/compiler/collisionSuperAndParameter.ts(21,7): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. +tests/cases/compiler/collisionSuperAndParameter.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionSuperAndParameter.ts(26,11): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. tests/cases/compiler/collisionSuperAndParameter.ts(32,19): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. tests/cases/compiler/collisionSuperAndParameter.ts(35,17): error TS2401: Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference. diff --git a/tests/baselines/reference/collisionThisExpressionAndLocalVarInAccessors.errors.txt b/tests/baselines/reference/collisionThisExpressionAndLocalVarInAccessors.errors.txt index 951a349be2b..cbe371c5934 100644 --- a/tests/baselines/reference/collisionThisExpressionAndLocalVarInAccessors.errors.txt +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarInAccessors.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(24,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(34,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(5,21): error TS2399: Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference. +tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(15,21): error TS2399: Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference. +tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(24,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(25,13): error TS2399: Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference. +tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(34,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/collisionThisExpressionAndLocalVarInAccessors.ts(35,13): error TS2399: Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference. diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.errors.txt b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.errors.txt index bbe47bb9544..6aeb5a7ec23 100644 --- a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.errors.txt +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(7,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(18,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(19,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(12,7): error TS2415: Class 'Derived' incorrectly extends base class 'Base'. Property 'x' is private in type 'Derived' but not in type 'Base'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(18,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(19,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(22,14): error TS2339: Property 'x' does not exist on type 'typeof Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(23,18): error TS2339: Property 'x' does not exist on type 'typeof Derived'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(25,15): error TS2339: Property 'fn' does not exist on type 'typeof Base'. diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.errors.txt b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.errors.txt index cfdf1381282..2e5d6f57c86 100644 --- a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.errors.txt +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(7,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(8,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(19,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(20,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(13,7): error TS2417: Class static side 'typeof Derived' incorrectly extends base class static side 'typeof Base'. Property 'x' is private in type 'typeof Derived' but not in type 'typeof Base'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(19,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(20,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(24,10): error TS2341: Property 'x' is private and only accessible within class 'Derived'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(27,10): error TS2341: Property 'fn' is private and only accessible within class 'Derived'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(32,10): error TS2341: Property 'a' is private and only accessible within class 'Derived'. diff --git a/tests/baselines/reference/duplicateClassElements.errors.txt b/tests/baselines/reference/duplicateClassElements.errors.txt index 004e68314fd..9dfec7a2908 100644 --- a/tests/baselines/reference/duplicateClassElements.errors.txt +++ b/tests/baselines/reference/duplicateClassElements.errors.txt @@ -1,27 +1,27 @@ -tests/cases/compiler/duplicateClassElements.ts(9,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/duplicateClassElements.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/duplicateClassElements.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/duplicateClassElements.ts(18,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/duplicateClassElements.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/duplicateClassElements.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/duplicateClassElements.ts(29,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/duplicateClassElements.ts(32,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/duplicateClassElements.ts(36,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/duplicateClassElements.ts(39,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(2,12): error TS2300: Duplicate identifier 'a'. tests/cases/compiler/duplicateClassElements.ts(3,12): error TS2300: Duplicate identifier 'a'. tests/cases/compiler/duplicateClassElements.ts(4,12): error TS2393: Duplicate function implementation. tests/cases/compiler/duplicateClassElements.ts(6,12): error TS2393: Duplicate function implementation. tests/cases/compiler/duplicateClassElements.ts(8,12): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/duplicateClassElements.ts(9,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(9,9): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/duplicateClassElements.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(12,9): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/duplicateClassElements.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/duplicateClassElements.ts(18,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(21,12): error TS2300: Duplicate identifier 'z'. +tests/cases/compiler/duplicateClassElements.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(23,9): error TS2300: Duplicate identifier 'z'. +tests/cases/compiler/duplicateClassElements.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(26,9): error TS2300: Duplicate identifier 'z'. +tests/cases/compiler/duplicateClassElements.ts(29,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(29,9): error TS2300: Duplicate identifier 'x2'. +tests/cases/compiler/duplicateClassElements.ts(32,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(32,9): error TS2300: Duplicate identifier 'x2'. tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2300: Duplicate identifier 'x2'. +tests/cases/compiler/duplicateClassElements.ts(36,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(36,9): error TS2300: Duplicate identifier 'z2'. +tests/cases/compiler/duplicateClassElements.ts(39,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(39,9): error TS2300: Duplicate identifier 'z2'. tests/cases/compiler/duplicateClassElements.ts(41,12): error TS2300: Duplicate identifier 'z2'. diff --git a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt index e192e99b87f..b273b1b6f45 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt +++ b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt @@ -1,11 +1,3 @@ -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(24,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(29,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(64,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(68,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(94,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(98,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(113,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(6,17): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(7,17): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(11,17): error TS2335: 'super' can only be referenced in a derived class. @@ -13,24 +5,32 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(15,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(16,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(21,9): error TS2335: 'super' can only be referenced in a derived class. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(24,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(25,9): error TS2335: 'super' can only be referenced in a derived class. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(29,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(30,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(57,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(61,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(64,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(68,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(94,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(95,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(98,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(99,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(109,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(110,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(111,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(113,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(114,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(115,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(116,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(122,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. diff --git a/tests/baselines/reference/errorsInGenericTypeReference.errors.txt b/tests/baselines/reference/errorsInGenericTypeReference.errors.txt index dcb5018f035..729b4db5440 100644 --- a/tests/baselines/reference/errorsInGenericTypeReference.errors.txt +++ b/tests/baselines/reference/errorsInGenericTypeReference.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/errorsInGenericTypeReference.ts(25,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/errorsInGenericTypeReference.ts(12,17): error TS2304: Cannot find name 'V'. tests/cases/compiler/errorsInGenericTypeReference.ts(18,31): error TS2304: Cannot find name 'V'. tests/cases/compiler/errorsInGenericTypeReference.ts(23,29): error TS2304: Cannot find name 'V'. tests/cases/compiler/errorsInGenericTypeReference.ts(24,36): error TS2304: Cannot find name 'V'. +tests/cases/compiler/errorsInGenericTypeReference.ts(25,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/errorsInGenericTypeReference.ts(25,27): error TS2304: Cannot find name 'V'. tests/cases/compiler/errorsInGenericTypeReference.ts(26,24): error TS2304: Cannot find name 'V'. tests/cases/compiler/errorsInGenericTypeReference.ts(31,36): error TS2304: Cannot find name 'V'. diff --git a/tests/baselines/reference/es6ClassTest2.errors.txt b/tests/baselines/reference/es6ClassTest2.errors.txt index bf87a809b77..0b68e1cd784 100644 --- a/tests/baselines/reference/es6ClassTest2.errors.txt +++ b/tests/baselines/reference/es6ClassTest2.errors.txt @@ -1,6 +1,6 @@ +tests/cases/compiler/es6ClassTest2.ts(17,1): error TS2304: Cannot find name 'console'. tests/cases/compiler/es6ClassTest2.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/es6ClassTest2.ts(35,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/es6ClassTest2.ts(17,1): error TS2304: Cannot find name 'console'. ==== tests/cases/compiler/es6ClassTest2.ts (3 errors) ==== diff --git a/tests/baselines/reference/fieldAndGetterWithSameName.errors.txt b/tests/baselines/reference/fieldAndGetterWithSameName.errors.txt index dd2374f2447..e78ccce2b83 100644 --- a/tests/baselines/reference/fieldAndGetterWithSameName.errors.txt +++ b/tests/baselines/reference/fieldAndGetterWithSameName.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/fieldAndGetterWithSameName.ts(3,7): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/fieldAndGetterWithSameName.ts(2,5): error TS2300: Duplicate identifier 'x'. +tests/cases/compiler/fieldAndGetterWithSameName.ts(3,7): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/fieldAndGetterWithSameName.ts(3,7): error TS2300: Duplicate identifier 'x'. diff --git a/tests/baselines/reference/functionAndPropertyNameConflict.errors.txt b/tests/baselines/reference/functionAndPropertyNameConflict.errors.txt index 640844064c4..a976048d0e3 100644 --- a/tests/baselines/reference/functionAndPropertyNameConflict.errors.txt +++ b/tests/baselines/reference/functionAndPropertyNameConflict.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/functionAndPropertyNameConflict.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/functionAndPropertyNameConflict.ts(2,12): error TS2300: Duplicate identifier 'aaaaa'. +tests/cases/compiler/functionAndPropertyNameConflict.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/functionAndPropertyNameConflict.ts(3,16): error TS2300: Duplicate identifier 'aaaaa'. diff --git a/tests/baselines/reference/genericReturnTypeFromGetter1.errors.txt b/tests/baselines/reference/genericReturnTypeFromGetter1.errors.txt index 8215d687443..6f5f68064a6 100644 --- a/tests/baselines/reference/genericReturnTypeFromGetter1.errors.txt +++ b/tests/baselines/reference/genericReturnTypeFromGetter1.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/genericReturnTypeFromGetter1.ts(6,7): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/genericReturnTypeFromGetter1.ts(5,18): error TS2314: Generic type 'A' requires 1 type argument(s). +tests/cases/compiler/genericReturnTypeFromGetter1.ts(6,7): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/compiler/genericReturnTypeFromGetter1.ts (2 errors) ==== diff --git a/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.errors.txt b/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.errors.txt index a7e8155c220..a11b0f0ad9e 100644 --- a/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.errors.txt +++ b/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(21,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(1,18): error TS2300: Duplicate identifier '_'. tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(1,41): error TS2304: Cannot find name '_'. tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(2,18): error TS2300: Duplicate identifier '_'. tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(2,34): error TS2304: Cannot find name '_'. tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(4,16): error TS2300: Duplicate identifier '_'. tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(15,15): error TS2300: Duplicate identifier '_'. +tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts(21,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/compiler/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts (7 errors) ==== diff --git a/tests/baselines/reference/getAndSetNotIdenticalType.errors.txt b/tests/baselines/reference/getAndSetNotIdenticalType.errors.txt index 5fe2e7ae321..6c55f966eee 100644 --- a/tests/baselines/reference/getAndSetNotIdenticalType.errors.txt +++ b/tests/baselines/reference/getAndSetNotIdenticalType.errors.txt @@ -1,23 +1,23 @@ -tests/cases/compiler/getAndSetNotIdenticalType.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/getAndSetNotIdenticalType.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/getAndSetNotIdenticalType.ts(2,5): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/compiler/getAndSetNotIdenticalType.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/getAndSetNotIdenticalType.ts(5,5): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/compiler/getAndSetNotIdenticalType.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/compiler/getAndSetNotIdenticalType.ts (4 errors) ==== class C { get x(): number { + ~~~~~~~~~~~~~~~~~ ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~~~ return 1; ~~~~~~~~~~~~~~~~~ } ~~~~~ !!! error TS2380: 'get' and 'set' accessor must have the same type. set x(v: string) { } - ~ -!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~~~~~~~~~~~~~~~~~~ !!! error TS2380: 'get' and 'set' accessor must have the same type. + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. } \ No newline at end of file diff --git a/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt b/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt index 69d367bb21c..5cdb9b3a36f 100644 --- a/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt +++ b/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,5): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,5): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/getAndSetNotIdenticalType2.ts(9,9): error TS2322: Type 'A' is not assignable to type 'A'. Type 'string' is not assignable to type 'T'. @@ -12,18 +12,18 @@ tests/cases/compiler/getAndSetNotIdenticalType2.ts(9,9): error TS2322: Type 'A { data: A; get x(): A { + ~~~~~~~~~~~~~~~ ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~ return this.data; ~~~~~~~~~~~~~~~~~~~~~~~~~ } ~~~~~ !!! error TS2380: 'get' and 'set' accessor must have the same type. set x(v: A) { + ~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~~~~~~~ this.data = v; ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ diff --git a/tests/baselines/reference/getAndSetNotIdenticalType3.errors.txt b/tests/baselines/reference/getAndSetNotIdenticalType3.errors.txt index bca86419f62..0aac384f7c3 100644 --- a/tests/baselines/reference/getAndSetNotIdenticalType3.errors.txt +++ b/tests/baselines/reference/getAndSetNotIdenticalType3.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/getAndSetNotIdenticalType3.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/getAndSetNotIdenticalType3.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/getAndSetNotIdenticalType3.ts(5,5): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/compiler/getAndSetNotIdenticalType3.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/getAndSetNotIdenticalType3.ts(8,5): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/compiler/getAndSetNotIdenticalType3.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/getAndSetNotIdenticalType3.ts(9,9): error TS2322: Type 'A' is not assignable to type 'A'. Type 'string' is not assignable to type 'number'. @@ -12,18 +12,18 @@ tests/cases/compiler/getAndSetNotIdenticalType3.ts(9,9): error TS2322: Type 'A { data: A; get x(): A { + ~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~~~~~~ return this.data; ~~~~~~~~~~~~~~~~~~~~~~~~~ } ~~~~~ !!! error TS2380: 'get' and 'set' accessor must have the same type. set x(v: A) { + ~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~~~~~~~ this.data = v; ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ diff --git a/tests/baselines/reference/gettersAndSetters.errors.txt b/tests/baselines/reference/gettersAndSetters.errors.txt index 2c287f30497..a4cc4b585e2 100644 --- a/tests/baselines/reference/gettersAndSetters.errors.txt +++ b/tests/baselines/reference/gettersAndSetters.errors.txt @@ -2,10 +2,10 @@ tests/cases/compiler/gettersAndSetters.ts(7,16): error TS1056: Accessors are onl tests/cases/compiler/gettersAndSetters.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSetters.ts(10,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSetters.ts(11,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/gettersAndSetters.ts(29,30): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/gettersAndSetters.ts(29,53): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSetters.ts(25,13): error TS2339: Property 'Baz' does not exist on type 'C'. tests/cases/compiler/gettersAndSetters.ts(26,3): error TS2339: Property 'Baz' does not exist on type 'C'. +tests/cases/compiler/gettersAndSetters.ts(29,30): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/gettersAndSetters.ts(29,53): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/compiler/gettersAndSetters.ts (8 errors) ==== diff --git a/tests/baselines/reference/gettersAndSettersAccessibility.errors.txt b/tests/baselines/reference/gettersAndSettersAccessibility.errors.txt index ddb8e95e5eb..faccaab8fdf 100644 --- a/tests/baselines/reference/gettersAndSettersAccessibility.errors.txt +++ b/tests/baselines/reference/gettersAndSettersAccessibility.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/gettersAndSettersAccessibility.ts(2,14): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/gettersAndSettersAccessibility.ts(3,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersAccessibility.ts(2,14): error TS2379: Getter and setter accessors do not agree in visibility. +tests/cases/compiler/gettersAndSettersAccessibility.ts(3,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersAccessibility.ts(3,13): error TS2379: Getter and setter accessors do not agree in visibility. diff --git a/tests/baselines/reference/gettersAndSettersErrors.errors.txt b/tests/baselines/reference/gettersAndSettersErrors.errors.txt index 95fb571d9b8..db2d4c5bc87 100644 --- a/tests/baselines/reference/gettersAndSettersErrors.errors.txt +++ b/tests/baselines/reference/gettersAndSettersErrors.errors.txt @@ -1,13 +1,13 @@ tests/cases/compiler/gettersAndSettersErrors.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/gettersAndSettersErrors.ts(2,16): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/gettersAndSettersErrors.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/gettersAndSettersErrors.ts(3,16): error TS2300: Duplicate identifier 'Foo'. +tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/gettersAndSettersErrors.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(7,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(11,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/gettersAndSettersErrors.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/gettersAndSettersErrors.ts(2,16): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/gettersAndSettersErrors.ts(3,16): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/gettersAndSettersErrors.ts(11,17): error TS2379: Getter and setter accessors do not agree in visibility. +tests/cases/compiler/gettersAndSettersErrors.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(12,16): error TS2379: Getter and setter accessors do not agree in visibility. diff --git a/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt b/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt index 6b86209b5b1..a07fbea75d8 100644 --- a/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt +++ b/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/illegalSuperCallsInConstructor.ts(11,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(15,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/illegalSuperCallsInConstructor.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/compiler/illegalSuperCallsInConstructor.ts(7,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors tests/cases/compiler/illegalSuperCallsInConstructor.ts(8,26): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors tests/cases/compiler/illegalSuperCallsInConstructor.ts(9,32): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(11,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/illegalSuperCallsInConstructor.ts(12,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(15,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors @@ -31,9 +31,9 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup var r5 = { ~~~~~~~~~~~~~~~~~~ get foo() { + ~~~~~~~~~~~~~~~~~~~~~~~ ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~~~~~~~~~ super(); ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ @@ -43,9 +43,9 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup }, ~~~~~~~~~~~~~~ set foo(v: number) { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ super(); ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ diff --git a/tests/baselines/reference/implicitAnyCastedValue.errors.txt b/tests/baselines/reference/implicitAnyCastedValue.errors.txt index 4b88cb0a8b4..613aa4820d2 100644 --- a/tests/baselines/reference/implicitAnyCastedValue.errors.txt +++ b/tests/baselines/reference/implicitAnyCastedValue.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/implicitAnyCastedValue.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/implicitAnyCastedValue.ts(28,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/implicitAnyCastedValue.ts(32,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/implicitAnyCastedValue.ts(10,5): error TS7008: Member 'bar' implicitly has an 'any' type. tests/cases/compiler/implicitAnyCastedValue.ts(11,5): error TS7008: Member 'foo' implicitly has an 'any' type. +tests/cases/compiler/implicitAnyCastedValue.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/implicitAnyCastedValue.ts(26,5): error TS7008: Member 'getValue' implicitly has an 'any' type. +tests/cases/compiler/implicitAnyCastedValue.ts(28,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/implicitAnyCastedValue.ts(32,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/implicitAnyCastedValue.ts(41,1): error TS7010: 'notCastedNull', which lacks return-type annotation, implicitly has an 'any' return type. tests/cases/compiler/implicitAnyCastedValue.ts(53,24): error TS7006: Parameter 'x' implicitly has an 'any' type. tests/cases/compiler/implicitAnyCastedValue.ts(62,24): error TS7006: Parameter 'x' implicitly has an 'any' type. diff --git a/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt b/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt index 9f2dc9ce949..4d9008cd56a 100644 --- a/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt +++ b/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt @@ -1,11 +1,11 @@ +tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(3,5): error TS7008: Member 'getAndSet' implicitly has an 'any' type. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(4,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(3,5): error TS7008: Member 'getAndSet' implicitly has an 'any' type. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,5): error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation. +tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,28): error TS7006: Parameter 'newXValue' implicitly has an 'any' type. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,5): error TS7010: 'haveOnlyGet', which lacks return-type annotation, implicitly has an 'any' return type. +tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts (8 errors) ==== @@ -30,9 +30,9 @@ tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,5): err class SetterOnly { public set haveOnlySet(newXValue) { // error at "haveOnlySet, newXValue" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS7006: Parameter 'newXValue' implicitly has an 'any' type. } @@ -42,9 +42,9 @@ tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,5): err class GetterOnly { public get haveOnlyGet() { // error at "haveOnlyGet" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return null; ~~~~~~~~~~~~~~~~~~~~ } diff --git a/tests/baselines/reference/inferSetterParamType.errors.txt b/tests/baselines/reference/inferSetterParamType.errors.txt index c9232d3fac7..2ae2a16f9d2 100644 --- a/tests/baselines/reference/inferSetterParamType.errors.txt +++ b/tests/baselines/reference/inferSetterParamType.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/inferSetterParamType.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inferSetterParamType.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(13,16): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/inferSetterParamType.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/compiler/inferSetterParamType.ts (5 errors) ==== diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt index 54f5fcc2a34..6fde83e08b0 100644 --- a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(7,7): error TS2415: Class 'b' incorrectly extends base class 'a'. Types of property 'x' are incompatible. Type 'string' is not assignable to type '() => string'. +tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(8,9): error TS2423: Class 'a' defines instance member function 'x', but extended class 'b' defines it as instance member accessor. +tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/compiler/inheritanceMemberAccessorOverridingMethod.ts (4 errors) ==== diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.errors.txt b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.errors.txt index 026c2b51ac9..38b1ed61fac 100644 --- a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.errors.txt +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/inheritanceStaticAccessorOverridingMethod.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inheritanceStaticAccessorOverridingMethod.ts(11,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inheritanceStaticAccessorOverridingMethod.ts(7,7): error TS2417: Class static side 'typeof b' incorrectly extends base class static side 'typeof a'. Types of property 'x' are incompatible. Type 'string' is not assignable to type '() => string'. +tests/cases/compiler/inheritanceStaticAccessorOverridingMethod.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/inheritanceStaticAccessorOverridingMethod.ts(11,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/compiler/inheritanceStaticAccessorOverridingMethod.ts (3 errors) ==== diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt index fbd64e5018e..340b5081866 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(26,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(29,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. diff --git a/tests/baselines/reference/instancePropertyInClassType.errors.txt b/tests/baselines/reference/instancePropertyInClassType.errors.txt index 9a7dce0f0cd..d14607d81bc 100644 --- a/tests/baselines/reference/instancePropertyInClassType.errors.txt +++ b/tests/baselines/reference/instancePropertyInClassType.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(24,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(27,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt index bd9a0bcbc93..35673eb3072 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt @@ -1,10 +1,8 @@ +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(18,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(21,5): error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(18,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(21,5): error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: number]: string | number; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'. @@ -12,6 +10,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo Type 'string | number' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts (11 errors) ==== diff --git a/tests/baselines/reference/objectLiteralGettersAndSetters.errors.txt b/tests/baselines/reference/objectLiteralGettersAndSetters.errors.txt index 4e04b856d8c..abc93a9cacc 100644 --- a/tests/baselines/reference/objectLiteralGettersAndSetters.errors.txt +++ b/tests/baselines/reference/objectLiteralGettersAndSetters.errors.txt @@ -22,12 +22,12 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetter tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(37,59): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(38,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(38,60): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(42,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(43,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(42,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(50,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(55,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(60,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(64,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(60,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(67,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(68,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(76,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/parserAstSpans1.errors.txt b/tests/baselines/reference/parserAstSpans1.errors.txt index e4360dafa53..9697dcbc128 100644 --- a/tests/baselines/reference/parserAstSpans1.errors.txt +++ b/tests/baselines/reference/parserAstSpans1.errors.txt @@ -2,9 +2,9 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(79,16): error TS10 tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(85,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(94,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(100,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(125,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration15.js b/tests/baselines/reference/parserMemberAccessorDeclaration15.js new file mode 100644 index 00000000000..59ff360d432 --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration15.js @@ -0,0 +1,17 @@ +//// [parserMemberAccessorDeclaration15.ts] +class C { + set Foo(public a: number) { } +} + +//// [parserMemberAccessorDeclaration15.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/propertyAndAccessorWithSameName.errors.txt b/tests/baselines/reference/propertyAndAccessorWithSameName.errors.txt index 9ef943cc07a..620f4dc5940 100644 --- a/tests/baselines/reference/propertyAndAccessorWithSameName.errors.txt +++ b/tests/baselines/reference/propertyAndAccessorWithSameName.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(10,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(18,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(2,5): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(3,9): error TS2300: Duplicate identifier 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(9,5): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(10,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(10,9): error TS2300: Duplicate identifier 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(14,13): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(15,9): error TS2300: Duplicate identifier 'x'. +tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(18,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/propertyMemberDeclarations/propertyAndAccessorWithSameName.ts(18,9): error TS2300: Duplicate identifier 'x'. diff --git a/tests/baselines/reference/staticPropertyNotInClassType.errors.txt b/tests/baselines/reference/staticPropertyNotInClassType.errors.txt index fb2a76f8d3c..62f04b5c5fb 100644 --- a/tests/baselines/reference/staticPropertyNotInClassType.errors.txt +++ b/tests/baselines/reference/staticPropertyNotInClassType.errors.txt @@ -1,10 +1,10 @@ tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(4,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(5,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(24,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(25,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(16,16): error TS2339: Property 'foo' does not exist on type 'C'. tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(17,16): error TS2339: Property 'bar' does not exist on type 'C'. tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(18,16): error TS2339: Property 'x' does not exist on type 'C'. +tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(24,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(25,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(27,21): error TS2302: Static members cannot reference class type parameters. tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(36,16): error TS2339: Property 'foo' does not exist on type 'C'. tests/cases/conformance/classes/members/classTypes/staticPropertyNotInClassType.ts(37,16): error TS2339: Property 'bar' does not exist on type 'C'. diff --git a/tests/baselines/reference/staticVisibility.errors.txt b/tests/baselines/reference/staticVisibility.errors.txt index 5d212f4fb9e..dccad4a2e2b 100644 --- a/tests/baselines/reference/staticVisibility.errors.txt +++ b/tests/baselines/reference/staticVisibility.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/staticVisibility.ts(31,12): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/staticVisibility.ts(33,12): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/staticVisibility.ts(10,9): error TS2304: Cannot find name 's'. tests/cases/compiler/staticVisibility.ts(13,9): error TS2304: Cannot find name 'b'. tests/cases/compiler/staticVisibility.ts(18,9): error TS2304: Cannot find name 'v'. tests/cases/compiler/staticVisibility.ts(19,14): error TS2339: Property 'p' does not exist on type 'typeof C1'. +tests/cases/compiler/staticVisibility.ts(31,12): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/staticVisibility.ts(33,12): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/staticVisibility.ts(33,29): error TS2304: Cannot find name 'barback'. diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index bdb122f6108..e3dfd6133c9 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -1,15 +1,13 @@ -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(13,5): error TS2411: Property 'b' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(14,5): error TS2411: Property 'c' of type '() => {}' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(16,5): error TS2411: Property '"e"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(18,5): error TS2411: Property '2.0' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(20,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(21,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(28,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(45,5): error TS2411: Property 'b' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(46,5): error TS2411: Property 'c' of type '() => {}' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(48,5): error TS2411: Property '"e"' of type 'number' is not assignable to string index type 'string'. @@ -28,6 +26,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon Index signatures are incompatible. Type 'string | number | MyString | (() => void)' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts (27 errors) ==== diff --git a/tests/baselines/reference/superPropertyAccess1.errors.txt b/tests/baselines/reference/superPropertyAccess1.errors.txt index f5b565cae6e..b256860ec72 100644 --- a/tests/baselines/reference/superPropertyAccess1.errors.txt +++ b/tests/baselines/reference/superPropertyAccess1.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/superPropertyAccess1.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess1.ts(22,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess1.ts(13,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword tests/cases/compiler/superPropertyAccess1.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess1.ts(22,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword diff --git a/tests/baselines/reference/superPropertyAccess2.errors.txt b/tests/baselines/reference/superPropertyAccess2.errors.txt index df9a5ee666b..475705f1506 100644 --- a/tests/baselines/reference/superPropertyAccess2.errors.txt +++ b/tests/baselines/reference/superPropertyAccess2.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/superPropertyAccess2.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess2.ts(22,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess2.ts(13,15): error TS2339: Property 'x' does not exist on type 'typeof C'. tests/cases/compiler/superPropertyAccess2.ts(18,15): error TS2339: Property 'bar' does not exist on type 'C'. tests/cases/compiler/superPropertyAccess2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess2.ts(22,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess2.ts(24,15): error TS2339: Property 'x' does not exist on type 'typeof C'. diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt index 9ec5b13ac65..44332e6e567 100644 --- a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(20,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(5,20): error TS2335: 'super' can only be referenced in a derived class. +tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(11,20): error TS2335: 'super' can only be referenced in a derived class. +tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(20,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class diff --git a/tests/baselines/reference/twoAccessorsWithSameName2.errors.txt b/tests/baselines/reference/twoAccessorsWithSameName2.errors.txt index 836a06a8192..59c15d73d5e 100644 --- a/tests/baselines/reference/twoAccessorsWithSameName2.errors.txt +++ b/tests/baselines/reference/twoAccessorsWithSameName2.errors.txt @@ -1,13 +1,13 @@ tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(2,16): error TS2300: Duplicate identifier 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(3,16): error TS2300: Duplicate identifier 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(7,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(7,16): error TS2300: Duplicate identifier 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(8,16): error TS2300: Duplicate identifier 'x'. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(15,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(2,16): error TS2300: Duplicate identifier 'x'. -tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(3,16): error TS2300: Duplicate identifier 'x'. -tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(7,16): error TS2300: Duplicate identifier 'x'. -tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts(8,16): error TS2300: Duplicate identifier 'x'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/twoAccessorsWithSameName2.ts (10 errors) ==== diff --git a/tests/baselines/reference/typeOfThisInInstanceMember.errors.txt b/tests/baselines/reference/typeOfThisInInstanceMember.errors.txt index bcfbaaad253..2685d2b34b8 100644 --- a/tests/baselines/reference/typeOfThisInInstanceMember.errors.txt +++ b/tests/baselines/reference/typeOfThisInInstanceMember.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInInstanceMember.ts(14,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInInstanceMember.ts(10,11): error TS2339: Property 'z' does not exist on type 'C'. +tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInInstanceMember.ts(14,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ==== tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInInstanceMember.ts (2 errors) ==== diff --git a/tests/baselines/reference/typeParametersInStaticAccessors.errors.txt b/tests/baselines/reference/typeParametersInStaticAccessors.errors.txt index b11542b0af2..644cd703cdf 100644 --- a/tests/baselines/reference/typeParametersInStaticAccessors.errors.txt +++ b/tests/baselines/reference/typeParametersInStaticAccessors.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/typeParametersInStaticAccessors.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/typeParametersInStaticAccessors.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/typeParametersInStaticAccessors.ts(2,29): error TS2302: Static members cannot reference class type parameters. +tests/cases/compiler/typeParametersInStaticAccessors.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/typeParametersInStaticAccessors.ts(3,28): error TS2302: Static members cannot reference class type parameters. From 003515655e4bb5d9b558b05c05616a2694604925 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 16 Dec 2014 12:51:42 -0800 Subject: [PATCH 65/74] Move grammar checking: methodDeclaration; there are still erros from incomplete grammar migration --- src/compiler/checker.ts | 43 +++++++++++++++++++ .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 +- src/compiler/parser.ts | 10 ++--- .../accessibilityModifiers.errors.txt | 8 ++-- ...OptionalParameterAndInitializer.errors.txt | 10 ++--- .../classWithOptionalParameter.errors.txt | 2 +- .../optionalArgsWithDefaultValues.errors.txt | 2 +- .../optionalParamArgsTest.errors.txt | 6 +-- .../parserParameterList10.errors.txt | 6 +-- .../reference/parserRealSource11.errors.txt | 2 +- ...eterWithoutAnnotationIsAnyArray.errors.txt | 2 +- .../restParametersOfNonArrayTypes.errors.txt | 2 +- .../restParametersOfNonArrayTypes2.errors.txt | 4 +- ...ametersWithArrayTypeAnnotations.errors.txt | 4 +- 15 files changed, 75 insertions(+), 31 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6cb38e98eaa..f2874ae5085 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6972,6 +6972,9 @@ module ts { } function checkObjectLiteralMethod(node: MethodDeclaration, contextualMapper?: TypeMapper): Type { + // Grammar checking + checkGrammarMethod(node); + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } @@ -7234,6 +7237,9 @@ module ts { function checkMethodDeclaration(node: MethodDeclaration) { // Grammar checking + // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration + checkGrammarMethod(node); + if (node.name.kind === SyntaxKind.ComputedPropertyName) { checkGrammarComputedPropertyName(node.name); } @@ -10378,6 +10384,43 @@ module ts { } } + function checkGrammarForDisallowedComputedProperty(node: DeclarationName, message: DiagnosticMessage) { + if (node.kind === SyntaxKind.ComputedPropertyName) { + return grammarErrorOnNode(node, message); + } + } + + function checkGrammarMethod(node: MethodDeclaration) { + if (checkGrammarFunctionLikeDeclaration(node) || + checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ false) || + checkGrammarForGenerator(node)) { + return true; + } + + if (node.parent.kind === SyntaxKind.ClassDeclaration) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, Diagnostics.A_class_member_cannot_be_declared_optional)) { + return true; + } + // Technically, computed properties in ambient contexts is disallowed + // for property declarations and accessors too, not just methods. + // However, property declarations disallow computed names in general, + // and accessors are not allowed in ambient contexts in general, + // so this error only really matters for methods. + if (isInAmbientContext(node)) { + return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context); + } + else if (!node.body) { + return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_method_overloads); + } + } + else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) { + return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces); + } + else if (node.parent.kind === SyntaxKind.TypeLiteral) { + return checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_type_literals); + } + } + function isIterationStatement(node: Node, lookInLabeledStatements: boolean): boolean { switch (node.kind) { case SyntaxKind.ForStatement: diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 085fb5c9654..2cc658621fb 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -39,7 +39,7 @@ module ts { A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional.", isEarly: true }, - A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, + A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer.", isEarly: true }, A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter.", isEarly: true }, A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter.", isEarly: true }, A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5d8f79eac42..9bcd486513b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -173,7 +173,8 @@ }, "A rest parameter cannot have an initializer.": { "category": "Error", - "code": 1048 + "code": 1048, + "isEarly": true }, "A 'set' accessor must have exactly one parameter.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 24f0dafaa27..f0c6fcc0e2a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4653,9 +4653,9 @@ module ts { //case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node); //case SyntaxKind.LabeledStatement: return checkLabeledStatement(node); //case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(node); - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - return checkMethod(node); + //case SyntaxKind.MethodDeclaration: + //case SyntaxKind.MethodSignature: + //return checkMethod(node); case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(node); //case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(node); //case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); @@ -5326,8 +5326,8 @@ module ts { //case SyntaxKind.Constructor: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: + //case SyntaxKind.MethodDeclaration: + //case SyntaxKind.MethodSignature: //case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.ModuleDeclaration: diff --git a/tests/baselines/reference/accessibilityModifiers.errors.txt b/tests/baselines/reference/accessibilityModifiers.errors.txt index f571c8e3ee0..5650fca5931 100644 --- a/tests/baselines/reference/accessibilityModifiers.errors.txt +++ b/tests/baselines/reference/accessibilityModifiers.errors.txt @@ -1,17 +1,17 @@ tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(22,12): error TS1029: 'private' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(23,12): error TS1029: 'private' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(27,12): error TS1029: 'protected' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(28,12): error TS1029: 'protected' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(32,12): error TS1029: 'public' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(33,12): error TS1029: 'public' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(40,13): error TS1028: Accessibility modifier already seen. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(41,12): error TS1028: Accessibility modifier already seen. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(23,12): error TS1029: 'private' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(24,12): error TS1029: 'private' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(25,12): error TS1029: 'private' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(28,12): error TS1029: 'protected' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(29,12): error TS1029: 'protected' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(30,12): error TS1029: 'protected' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(33,12): error TS1029: 'public' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(34,12): error TS1029: 'public' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(35,12): error TS1029: 'public' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(41,12): error TS1028: Accessibility modifier already seen. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(42,13): error TS1028: Accessibility modifier already seen. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(43,12): error TS1028: Accessibility modifier already seen. diff --git a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt index eec5ea18afc..63a63309c31 100644 --- a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt +++ b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt @@ -1,17 +1,17 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(3,14): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(4,22): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(15,9): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(44,9): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(5,22): error TS1015: Parameter cannot have question mark and initializer. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(15,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(23,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(24,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(34,6): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(34,6): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(44,9): error TS1015: Parameter cannot have question mark and initializer. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(46,9): error TS1015: Parameter cannot have question mark and initializer. diff --git a/tests/baselines/reference/classWithOptionalParameter.errors.txt b/tests/baselines/reference/classWithOptionalParameter.errors.txt index 6e512c2a02e..3d1ba523d14 100644 --- a/tests/baselines/reference/classWithOptionalParameter.errors.txt +++ b/tests/baselines/reference/classWithOptionalParameter.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts(4,6): error TS1112: A class member cannot be declared optional. -tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts(5,6): error TS1112: A class member cannot be declared optional. tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts(9,6): error TS1112: A class member cannot be declared optional. +tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts(5,6): error TS1112: A class member cannot be declared optional. tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts(10,6): error TS1112: A class member cannot be declared optional. diff --git a/tests/baselines/reference/optionalArgsWithDefaultValues.errors.txt b/tests/baselines/reference/optionalArgsWithDefaultValues.errors.txt index 784f8b64e2a..414e718ac71 100644 --- a/tests/baselines/reference/optionalArgsWithDefaultValues.errors.txt +++ b/tests/baselines/reference/optionalArgsWithDefaultValues.errors.txt @@ -1,6 +1,6 @@ +tests/cases/compiler/optionalArgsWithDefaultValues.ts(1,25): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/optionalArgsWithDefaultValues.ts(4,27): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/optionalArgsWithDefaultValues.ts(5,28): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/compiler/optionalArgsWithDefaultValues.ts(1,25): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/optionalArgsWithDefaultValues.ts(8,10): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/optionalArgsWithDefaultValues.ts(9,13): error TS1015: Parameter cannot have question mark and initializer. diff --git a/tests/baselines/reference/optionalParamArgsTest.errors.txt b/tests/baselines/reference/optionalParamArgsTest.errors.txt index a8ce88e494e..3c4d2e37be9 100644 --- a/tests/baselines/reference/optionalParamArgsTest.errors.txt +++ b/tests/baselines/reference/optionalParamArgsTest.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/optionalParamArgsTest.ts(35,47): error TS1016: A required parameter cannot follow an optional parameter. tests/cases/compiler/optionalParamArgsTest.ts(31,12): error TS2393: Duplicate function implementation. tests/cases/compiler/optionalParamArgsTest.ts(35,12): error TS2393: Duplicate function implementation. +tests/cases/compiler/optionalParamArgsTest.ts(35,47): error TS1016: A required parameter cannot follow an optional parameter. tests/cases/compiler/optionalParamArgsTest.ts(99,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/optionalParamArgsTest.ts(100,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/optionalParamArgsTest.ts(101,1): error TS2346: Supplied parameters do not match any signature of call target. @@ -61,10 +61,10 @@ tests/cases/compiler/optionalParamArgsTest.ts(118,1): error TS2346: Supplied par // Negative test // "Optional parameters may only be followed by other optional parameters" public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; } - ~~~~~~ -!!! error TS1016: A required parameter cannot follow an optional parameter. ~~~~ !!! error TS2393: Duplicate function implementation. + ~~~~~~ +!!! error TS1016: A required parameter cannot follow an optional parameter. } class C2 extends C1 { diff --git a/tests/baselines/reference/parserParameterList10.errors.txt b/tests/baselines/reference/parserParameterList10.errors.txt index 5239280d589..2737dc5efed 100644 --- a/tests/baselines/reference/parserParameterList10.errors.txt +++ b/tests/baselines/reference/parserParameterList10.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList10.ts(2,11): error TS1048: A rest parameter cannot have an initializer. tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList10.ts(2,8): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList10.ts(2,11): error TS1048: A rest parameter cannot have an initializer. ==== tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList10.ts (2 errors) ==== class C { foo(...bar = 0) { } - ~~~ -!!! error TS1048: A rest parameter cannot have an initializer. ~~~~~~~~~~ !!! error TS2370: A rest parameter must be of an array type. + ~~~ +!!! error TS1048: A rest parameter cannot have an initializer. } \ No newline at end of file diff --git a/tests/baselines/reference/parserRealSource11.errors.txt b/tests/baselines/reference/parserRealSource11.errors.txt index dc314c8d3e2..bf5432062b0 100644 --- a/tests/baselines/reference/parserRealSource11.errors.txt +++ b/tests/baselines/reference/parserRealSource11.errors.txt @@ -1,5 +1,4 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. -tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(867,29): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(13,22): error TS2304: Cannot find name 'Type'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(14,24): error TS2304: Cannot find name 'ASTFlags'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(17,38): error TS2304: Cannot find name 'CompilerDiagnostics'. @@ -215,6 +214,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(838,24): error tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(841,61): error TS2304: Cannot find name 'TypeSymbol'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(850,52): error TS2304: Cannot find name 'TokenID'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(863,36): error TS2304: Cannot find name 'TypeFlow'. +tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(867,29): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(868,38): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(877,40): error TS2304: Cannot find name 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(891,27): error TS2304: Cannot find name 'VarFlags'. diff --git a/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt b/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt index 72614738ed9..0177f1e9a1c 100644 --- a/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt +++ b/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParameterWithoutAnnotationIsAnyArray.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt b/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt index 6c3c8f5fe19..d2afe977fd0 100644 --- a/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt +++ b/tests/baselines/reference/restParametersOfNonArrayTypes.errors.txt @@ -1,4 +1,3 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(3,14): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(4,22): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. @@ -6,6 +5,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfN tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(5,23): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(8,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(12,6): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(13,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(13,23): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes.ts(17,6): error TS2370: A rest parameter must be of an array type. diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt b/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt index aeae6846dcc..654f053e8bb 100644 --- a/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt +++ b/tests/baselines/reference/restParametersOfNonArrayTypes2.errors.txt @@ -1,5 +1,3 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(17,9): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(44,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(7,14): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(8,22): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,11): error TS1014: A rest parameter must be last in a parameter list. @@ -7,6 +5,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfN tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(9,26): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(12,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(16,6): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(17,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(17,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(17,24): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(21,6): error TS2370: A rest parameter must be of an array type. @@ -23,6 +22,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfN tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(36,35): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(39,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(43,6): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(44,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(44,9): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(44,33): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersOfNonArrayTypes2.ts(48,6): error TS2370: A rest parameter must be of an array type. diff --git a/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt b/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt index bd813e8fc55..06b2caefb9d 100644 --- a/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt +++ b/tests/baselines/reference/restParametersWithArrayTypeAnnotations.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(40,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(5,11): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(13,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(23,21): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(32,11): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(40,9): error TS1014: A rest parameter must be last in a parameter list. tests/cases/conformance/types/objectTypeLiteral/callSignatures/restParametersWithArrayTypeAnnotations.ts(50,21): error TS1014: A rest parameter must be last in a parameter list. From c525877aaa2586f7ae2fee8682860a7775e87392 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 16 Dec 2014 13:35:31 -0800 Subject: [PATCH 66/74] Move grammar checking: moduleDeclaration; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 21 +++++++++++++++++++ src/compiler/parser.ts | 4 ++-- .../reference/declareAlreadySeen.errors.txt | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f2874ae5085..455442a6317 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8880,6 +8880,27 @@ module ts { } function checkModuleDeclaration(node: ModuleDeclaration) { + // Grammar checking + if (!checkGrammarModifiers(node)) { + if (!isInAmbientContext(node) && node.name.kind === SyntaxKind.StringLiteral) { + grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names); + } + else if (node.name.kind === SyntaxKind.Identifier && node.body.kind === SyntaxKind.ModuleBlock) { + var statements = (node.body).statements; + for (var i = 0, n = statements.length; i < n; i++) { + var statement = statements[i]; + + if (statement.kind === SyntaxKind.ExportAssignment) { + // Export assignments are not allowed in an internal module + grammarErrorOnNode(statement, Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); + } + else if (isExternalModuleImportDeclaration(statement)) { + grammarErrorOnNode(getExternalModuleImportDeclarationExpression(statement), Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); + } + } + } + } + if (fullTypeCheck) { checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f0c6fcc0e2a..4aa2eb6b203 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4656,7 +4656,7 @@ module ts { //case SyntaxKind.MethodDeclaration: //case SyntaxKind.MethodSignature: //return checkMethod(node); - case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(node); + //case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(node); //case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(node); //case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); //case SyntaxKind.Parameter: return checkParameter(node); @@ -5330,7 +5330,7 @@ module ts { //case SyntaxKind.MethodSignature: //case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.ModuleDeclaration: + //case SyntaxKind.ModuleDeclaration: //case SyntaxKind.EnumDeclaration: case SyntaxKind.ExportAssignment: //case SyntaxKind.VariableStatement: diff --git a/tests/baselines/reference/declareAlreadySeen.errors.txt b/tests/baselines/reference/declareAlreadySeen.errors.txt index da671ad313a..d606b571478 100644 --- a/tests/baselines/reference/declareAlreadySeen.errors.txt +++ b/tests/baselines/reference/declareAlreadySeen.errors.txt @@ -1,6 +1,6 @@ -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(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(7,13): error TS1030: 'declare' modifier already seen. From 406576f1fc704234cd2081c023386b0e364ed1a2 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 16 Dec 2014 13:36:00 -0800 Subject: [PATCH 67/74] Move grammar checking: propertyDeclaration, propertySignature; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 26 +++++++++++++++++++ src/compiler/parser.ts | 10 +++---- .../accessibilityModifiers.errors.txt | 6 ++--- .../classWithOptionalParameter.errors.txt | 2 +- ...SignatureMustHaveTypeAnnotation.errors.txt | 2 +- ...ModuleWithStatementsOfEveryKind.errors.txt | 6 ++--- .../parserComputedPropertyName29.errors.txt | 2 +- 7 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 455442a6317..99df47de0eb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7232,6 +7232,9 @@ module ts { } function checkPropertyDeclaration(node: PropertyDeclaration) { + // Grammar checking + checkGrammarModifiers(node) || checkGrammarProperty(node); + checkVariableLikeDeclaration(node); } @@ -10701,6 +10704,29 @@ module ts { } } + function checkGrammarProperty(node: PropertyDeclaration) { + if (node.parent.kind === SyntaxKind.ClassDeclaration) { + if (checkGrammarForInvalidQuestionMark(node, node.questionToken, Diagnostics.A_class_member_cannot_be_declared_optional) || + checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_class_property_declarations)) { + return true; + } + } + else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) { + if (checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces)) { + return true; + } + } + else if (node.parent.kind === SyntaxKind.TypeLiteral) { + if (checkGrammarForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_type_literals)) { + return true; + } + } + + if (isInAmbientContext(node) && node.initializer) { + return grammarErrorOnFirstToken(node.initializer, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + } + } + function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { var sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 4aa2eb6b203..edc9c8f8581 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4662,9 +4662,9 @@ module ts { //case SyntaxKind.Parameter: return checkParameter(node); //case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); //case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - return checkProperty(node); + //case SyntaxKind.PropertyDeclaration: + //case SyntaxKind.PropertySignature: + //return checkProperty(node); //case SyntaxKind.ReturnStatement: return checkReturnStatement(node); //case SyntaxKind.SetAccessor: return checkSetAccessor(node); case SyntaxKind.SourceFile: return checkSourceFile(node); @@ -5324,8 +5324,8 @@ module ts { //case SyntaxKind.GetAccessor: //case SyntaxKind.SetAccessor: //case SyntaxKind.Constructor: - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: + //case SyntaxKind.PropertyDeclaration: + //case SyntaxKind.PropertySignature: //case SyntaxKind.MethodDeclaration: //case SyntaxKind.MethodSignature: //case SyntaxKind.ClassDeclaration: diff --git a/tests/baselines/reference/accessibilityModifiers.errors.txt b/tests/baselines/reference/accessibilityModifiers.errors.txt index 5650fca5931..1bf92139761 100644 --- a/tests/baselines/reference/accessibilityModifiers.errors.txt +++ b/tests/baselines/reference/accessibilityModifiers.errors.txt @@ -1,16 +1,16 @@ tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(22,12): error TS1029: 'private' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(27,12): error TS1029: 'protected' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(32,12): error TS1029: 'public' modifier must precede 'static' modifier. -tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(40,13): error TS1028: Accessibility modifier already seen. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(23,12): error TS1029: 'private' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(24,12): error TS1029: 'private' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(25,12): error TS1029: 'private' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(27,12): error TS1029: 'protected' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(28,12): error TS1029: 'protected' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(29,12): error TS1029: 'protected' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(30,12): error TS1029: 'protected' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(32,12): error TS1029: 'public' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(33,12): error TS1029: 'public' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(34,12): error TS1029: 'public' modifier must precede 'static' modifier. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(35,12): error TS1029: 'public' modifier must precede 'static' modifier. +tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(40,13): error TS1028: Accessibility modifier already seen. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(41,12): error TS1028: Accessibility modifier already seen. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(42,13): error TS1028: Accessibility modifier already seen. tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts(43,12): error TS1028: Accessibility modifier already seen. diff --git a/tests/baselines/reference/classWithOptionalParameter.errors.txt b/tests/baselines/reference/classWithOptionalParameter.errors.txt index 3d1ba523d14..6e512c2a02e 100644 --- a/tests/baselines/reference/classWithOptionalParameter.errors.txt +++ b/tests/baselines/reference/classWithOptionalParameter.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts(4,6): error TS1112: A class member cannot be declared optional. -tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts(9,6): error TS1112: A class member cannot be declared optional. tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts(5,6): error TS1112: A class member cannot be declared optional. +tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts(9,6): error TS1112: A class member cannot be declared optional. tests/cases/conformance/types/namedTypes/classWithOptionalParameter.ts(10,6): error TS1112: A class member cannot be declared optional. diff --git a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt index 7d348b2cdbc..294282d1e9e 100644 --- a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt +++ b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(2,5): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(7,5): error TS1166: Computed property names are not allowed in class property declarations. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1021: An index signature must have a type annotation. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(7,5): error TS1166: Computed property names are not allowed in class property declarations. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(12,5): error TS1021: An index signature must have a type annotation. diff --git a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt index 0d2ef3d6924..1169256aed6 100644 --- a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt +++ b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt @@ -1,23 +1,23 @@ tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(13,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(19,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(38,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(44,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(64,5): error TS1044: 'static' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(70,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(4,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(6,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(12,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(15,5): error TS1044: 'public' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(19,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(25,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(29,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(31,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(37,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(40,5): error TS1044: 'private' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(44,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(50,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(55,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(57,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(63,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(66,5): error TS1044: 'static' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(70,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(76,5): error TS1044: 'static' modifier cannot appear on a module element. diff --git a/tests/baselines/reference/parserComputedPropertyName29.errors.txt b/tests/baselines/reference/parserComputedPropertyName29.errors.txt index 13a15bf5f9d..691a240375a 100644 --- a/tests/baselines/reference/parserComputedPropertyName29.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName29.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,5): error TS1166: Computed property names are not allowed in class property declarations. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1166: Computed property names are not allowed in class property declarations. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,11): error TS2304: Cannot find name 'id'. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1166: Computed property names are not allowed in class property declarations. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts (3 errors) ==== From a3e8b6c6d711d1d65b434651f7a71e0f646c8ef5 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 16 Dec 2014 13:47:57 -0800 Subject: [PATCH 68/74] Move grammar checking: interfaceDeclaration-remove it from checkModifiers in parser; there are still errors from incomplete grammar migration --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 ++- src/compiler/parser.ts | 2 +- .../invalidModuleWithStatementsOfEveryKind.errors.txt | 6 +++--- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 99df47de0eb..28a398ec40d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8614,7 +8614,7 @@ module ts { function checkInterfaceDeclaration(node: InterfaceDeclaration) { // Grammar checking - checkGrammarInterfaceDeclaration(node); + checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node); checkTypeParameters(node.typeParameters); if (fullTypeCheck) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 2cc658621fb..9885cdcca12 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -36,7 +36,7 @@ module ts { A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context.", isEarly: true }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts.", isEarly: true }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element.", isEarly: true }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, + A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration.", isEarly: true }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional.", isEarly: true }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9bcd486513b..7f45cda8f04 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -160,7 +160,8 @@ }, "A 'declare' modifier cannot be used with an interface declaration.": { "category": "Error", - "code": 1045 + "code": 1045, + "isEarly": true }, "A 'declare' modifier is required for a top level declaration in a .d.ts file.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index edc9c8f8581..49871d790a2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5329,7 +5329,7 @@ module ts { //case SyntaxKind.MethodDeclaration: //case SyntaxKind.MethodSignature: //case SyntaxKind.ClassDeclaration: - case SyntaxKind.InterfaceDeclaration: + //case SyntaxKind.InterfaceDeclaration: //case SyntaxKind.ModuleDeclaration: //case SyntaxKind.EnumDeclaration: case SyntaxKind.ExportAssignment: diff --git a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt index 1169256aed6..101ee0124cc 100644 --- a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt +++ b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.errors.txt @@ -1,21 +1,21 @@ -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(13,5): error TS1044: 'public' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(38,5): error TS1044: 'private' modifier cannot appear on a module element. -tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(64,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(4,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(6,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(12,5): error TS1044: 'public' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(13,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(15,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(19,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(25,5): error TS1044: 'public' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(29,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(31,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(37,5): error TS1044: 'private' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(38,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(40,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(44,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(50,5): error TS1044: 'private' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(55,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(57,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(63,5): error TS1044: 'static' modifier cannot appear on a module element. +tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(64,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(66,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(70,5): error TS1044: 'static' modifier cannot appear on a module element. tests/cases/conformance/internalModules/moduleBody/invalidModuleWithStatementsOfEveryKind.ts(76,5): error TS1044: 'static' modifier cannot appear on a module element. From 8dc9f751a3da213af79c3e11ffa2a774afa46983 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 16 Dec 2014 17:32:15 -0800 Subject: [PATCH 69/74] Complete grammar checking migration; there are still errors which will be fixed once pull master into the branch --- src/compiler/checker.ts | 111 +++++++++- .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 198 +++++++++--------- src/compiler/parser.ts | 38 ++-- src/compiler/types.ts | 1 + .../reference/ambientErrors.errors.txt | 16 +- 6 files changed, 243 insertions(+), 122 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 28a398ec40d..81280618d02 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7826,6 +7826,11 @@ module ts { } function checkBlock(node: Block) { + // Grammar checking for SyntaxKind.Block + if (node.kind === SyntaxKind.Block) { + checkGrammarForStatementInAmbientContext(node); + } + forEach(node.statements, checkSourceElement); if (isFunctionBlock(node) || node.kind === SyntaxKind.ModuleBlock) { checkFunctionExpressionBodies(node); @@ -8085,27 +8090,40 @@ module ts { } function checkExpressionStatement(node: ExpressionStatement) { + // Grammar checking + checkGrammarForStatementInAmbientContext(node) + checkExpression(node.expression); } function checkIfStatement(node: IfStatement) { + // Grammar checking + checkGrammarForStatementInAmbientContext(node); + checkExpression(node.expression); checkSourceElement(node.thenStatement); checkSourceElement(node.elseStatement); } function checkDoStatement(node: DoStatement) { + // Grammar checking + checkGrammarForStatementInAmbientContext(node); + checkSourceElement(node.statement); checkExpression(node.expression); } function checkWhileStatement(node: WhileStatement) { + // Grammar checking + checkGrammarForStatementInAmbientContext(node); + checkExpression(node.expression); checkSourceElement(node.statement); } function checkForStatement(node: ForStatement) { // Grammar checking + checkGrammarForStatementInAmbientContext(node); checkGrammarVariableDeclarations(node, node.declarations); if (node.declarations) forEach(node.declarations, checkVariableLikeDeclaration); @@ -8116,7 +8134,9 @@ module ts { } function checkForInStatement(node: ForInStatement) { - // Grammar checking + // Grammar checkingcheck + checkGrammarForStatementInAmbientContext(node); + var declarations = node.declarations; if (!checkGrammarVariableDeclarations(node, declarations)) { if (declarations && declarations.length > 1) { @@ -8166,6 +8186,7 @@ module ts { function checkBreakOrContinueStatement(node: BreakOrContinueStatement) { // Grammar checking + checkGrammarForStatementInAmbientContext(node); checkGrammarBreakOrContinueStatement(node); // TODO: Check that target label is valid @@ -8177,6 +8198,7 @@ module ts { function checkReturnStatement(node: ReturnStatement) { // Grammar checking + checkGrammarForStatementInAmbientContext(node); var parent = node.parent; var inFunctionBlock = false; var functionBlock = getContainingFunction(node); @@ -8208,6 +8230,8 @@ module ts { function checkWithStatement(node: WithStatement) { // Grammar checking for withStatement + checkGrammarForStatementInAmbientContext(node); + if (node.parserContextFlags & ParserContextFlags.StrictMode) { grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); } @@ -8224,6 +8248,8 @@ module ts { function checkSwitchStatement(node: SwitchStatement) { // Grammar checking + checkGrammarForStatementInAmbientContext(node); + var firstDefaultClause: CaseOrDefaultClause; var hasDuplicateDefaultClause = false; @@ -8258,8 +8284,8 @@ module ts { } function checkLabeledStatement(node: LabeledStatement) { - // ensure that label is unique // Grammar checking + checkGrammarForStatementInAmbientContext(node); var current = node.parent; while (current) { if (isAnyFunction(current)) { @@ -8273,10 +8299,15 @@ module ts { current = current.parent; } + // ensure that label is unique checkSourceElement(node.statement); } function checkThrowStatement(node: ThrowStatement) { + // Grammar checking + checkGrammarForStatementInAmbientContext(node) + + // Type checking if (node.expression === undefined) { grammarErrorAfterFirstToken(node, Diagnostics.Line_break_not_permitted_here); } @@ -8287,6 +8318,9 @@ module ts { } function checkTryStatement(node: TryStatement) { + // Grammar checking + checkGrammarForStatementInAmbientContext(node); + checkBlock(node.tryBlock); var catchClause = node.catchClause; if (catchClause) { @@ -9108,6 +9142,10 @@ module ts { return checkImportDeclaration(node); case SyntaxKind.ExportAssignment: return checkExportAssignment(node); + case SyntaxKind.EmptyStatement: + return checkGrammarForStatementInAmbientContext(node); + case SyntaxKind.DebuggerStatement: + return checkGrammarForStatementInAmbientContext(node); } } @@ -9199,6 +9237,9 @@ module ts { // Fully type check a source file and collect the relevant diagnostics. function checkSourceFile(node: SourceFile) { + // Grammar checking + checkGrammarSourceFile(node); + var links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { emitExtends = false; @@ -10697,6 +10738,7 @@ module ts { function checkGrammarForBodyInAmbientContext(body: Block | Expression, isConstructor: boolean): boolean { if (isInAmbientContext(body) && body && body.kind === SyntaxKind.Block) { + var diagnostic = isConstructor ? Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; @@ -10727,6 +10769,71 @@ module ts { } } + function checkGrammarTopLevelElementForRequiredDeclareModifier(node: Node): boolean { + // A declare modifier is required for any top level .d.ts declaration except export=, interfaces and imports: + // categories: + // + // DeclarationElement: + // ExportAssignment + // export_opt InterfaceDeclaration + // export_opt ImportDeclaration + // export_opt ExternalImportDeclaration + // export_opt AmbientDeclaration + // + if (node.kind === SyntaxKind.InterfaceDeclaration || + node.kind === SyntaxKind.ImportDeclaration || + node.kind === SyntaxKind.ExportAssignment || + (node.flags & NodeFlags.Ambient)) { + + return false; + } + + return grammarErrorOnFirstToken(node, Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); + } + + function checkGrammarTopLevelElementsForRequiredDeclareModifier(file: SourceFile): boolean { + for (var i = 0, n = file.statements.length; i < n; i++) { + var decl = file.statements[i]; + if (isDeclaration(decl) || decl.kind === SyntaxKind.VariableStatement) { + if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { + return true; + } + } + } + } + + function checkGrammarSourceFile(node: SourceFile): boolean { + return isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + } + + function checkGrammarForStatementInAmbientContext(node: Node): void { + if (isInAmbientContext(node)) { + // Find containing block which is either Block, ModuleBlock, SourceFile + if (isAnyFunction(node.parent)) { + grammarErrorOnFirstToken(node, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts) + return; + } + + // We are either parented by another statement, or some sort of block. + // If we're in a block, we only want to really report an error once + // to prevent noisyness. So use a bit on the block to indicate if + // this has already been reported, and don't report if it has. + // + if (node.parent.kind === SyntaxKind.Block || node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { + var links = getNodeLinks(node.parent); + // Check if the containing block ever report this error + if (!links.hasReportedStatementInAmbientContext) { + links.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.Statements_are_not_allowed_in_ambient_contexts); + } + } + else { + // We must be parented by a statement. If so, there's no need + // to report the error as our parent will have already done it. + // Debug.assert(isStatement(node.parent)); + } + } + } + function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { var sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 9885cdcca12..31f43f8f42b 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -144,6 +144,7 @@ module ts { Array_element_destructuring_pattern_expected: { code: 1181, category: DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer.", isEarly: true }, Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts.", isEarly: true }, + An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts.", isEarly: true }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7f45cda8f04..868efbf6edb 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -10,7 +10,7 @@ "'{0}' expected.": { "category": "Error", "code": 1005, - "isEarly": true + "isEarly": true }, "A file cannot have a reference to itself.": { "category": "Error", @@ -19,7 +19,7 @@ "Trailing comma not allowed.": { "category": "Error", "code": 1009, - "isEarly": true + "isEarly": true }, "'*/' expected.": { "category": "Error", @@ -32,57 +32,57 @@ "Catch clause parameter cannot have a type annotation.": { "category": "Error", "code": 1013, - "isEarly": true + "isEarly": true }, "A rest parameter must be last in a parameter list.": { "category": "Error", "code": 1014, - "isEarly": true + "isEarly": true }, "Parameter cannot have question mark and initializer.": { "category": "Error", "code": 1015, - "isEarly": true + "isEarly": true }, "A required parameter cannot follow an optional parameter.": { "category": "Error", "code": 1016, - "isEarly": true + "isEarly": true }, "An index signature cannot have a rest parameter.": { "category": "Error", "code": 1017, - "isEarly": true + "isEarly": true }, "An index signature parameter cannot have an accessibility modifier.": { "category": "Error", "code": 1018, - "isEarly": true + "isEarly": true }, "An index signature parameter cannot have a question mark.": { "category": "Error", "code": 1019, - "isEarly": true + "isEarly": true }, "An index signature parameter cannot have an initializer.": { "category": "Error", "code": 1020, - "isEarly": true + "isEarly": true }, "An index signature must have a type annotation.": { "category": "Error", "code": 1021, - "isEarly": true + "isEarly": true }, "An index signature parameter must have a type annotation.": { "category": "Error", "code": 1022, - "isEarly": true + "isEarly": true }, "An index signature parameter type must be 'string' or 'number'.": { "category": "Error", "code": 1023, - "isEarly": true + "isEarly": true }, "A class or interface declaration can only have one 'extends' clause.": { "category": "Error", @@ -103,22 +103,22 @@ "Accessibility modifier already seen.": { "category": "Error", "code": 1028, - "isEarly": true + "isEarly": true }, "'{0}' modifier must precede '{1}' modifier.": { "category": "Error", "code": 1029, - "isEarly": true + "isEarly": true }, "'{0}' modifier already seen.": { "category": "Error", "code": 1030, - "isEarly": true + "isEarly": true }, "'{0}' modifier cannot appear on a class element.": { "category": "Error", "code": 1031, - "isEarly": true + "isEarly": true }, "An interface declaration cannot have an 'implements' clause.": { "category": "Error", @@ -131,37 +131,37 @@ "Only ambient modules can use quoted names.": { "category": "Error", "code": 1035, - "isEarly": true + "isEarly": true }, "Statements are not allowed in ambient contexts.": { "category": "Error", "code": 1036, - "isEarly": true + "isEarly": true }, "A function implementation cannot be declared in an ambient context.": { "category": "Error", "code": 1037, - "isEarly": true + "isEarly": true }, "A 'declare' modifier cannot be used in an already ambient context.": { "category": "Error", "code": 1038, - "isEarly": true + "isEarly": true }, "Initializers are not allowed in ambient contexts.": { "category": "Error", "code": 1039, - "isEarly": true + "isEarly": true }, "'{0}' modifier cannot appear on a module element.": { "category": "Error", "code": 1044, - "isEarly": true + "isEarly": true }, "A 'declare' modifier cannot be used with an interface declaration.": { "category": "Error", "code": 1045, - "isEarly": true + "isEarly": true }, "A 'declare' modifier is required for a top level declaration in a .d.ts file.": { "category": "Error", @@ -170,57 +170,57 @@ "A rest parameter cannot be optional.": { "category": "Error", "code": 1047, - "isEarly": true + "isEarly": true }, "A rest parameter cannot have an initializer.": { "category": "Error", "code": 1048, - "isEarly": true + "isEarly": true }, "A 'set' accessor must have exactly one parameter.": { "category": "Error", "code": 1049, - "isEarly": true + "isEarly": true }, "A 'set' accessor cannot have an optional parameter.": { "category": "Error", "code": 1051, - "isEarly": true + "isEarly": true }, "A 'set' accessor parameter cannot have an initializer.": { "category": "Error", "code": 1052, - "isEarly": true + "isEarly": true }, "A 'set' accessor cannot have rest parameter.": { "category": "Error", "code": 1053, - "isEarly": true + "isEarly": true }, "A 'get' accessor cannot have parameters.": { "category": "Error", "code": 1054, - "isEarly": true + "isEarly": true }, "Accessors are only available when targeting ECMAScript 5 and higher.": { "category": "Error", "code": 1056, - "isEarly": true + "isEarly": true }, "Enum member must have initializer.": { "category": "Error", "code": 1061, - "isEarly": true + "isEarly": true }, "An export assignment cannot be used in an internal module.": { "category": "Error", "code": 1063, - "isEarly": true + "isEarly": true }, "Ambient enum elements can only have integer literal initializers.": { "category": "Error", "code": 1066, - "isEarly": true + "isEarly": true }, "Unexpected token. A constructor, method, accessor, or property was expected.": { "category": "Error", @@ -237,107 +237,107 @@ "Octal literals are not available when targeting ECMAScript 5 and higher.": { "category": "Error", "code": 1085, - "isEarly": true + "isEarly": true }, "An accessor cannot be declared in an ambient context.": { "category": "Error", "code": 1086, - "isEarly": true + "isEarly": true }, "'{0}' modifier cannot appear on a constructor declaration.": { "category": "Error", "code": 1089, - "isEarly": true + "isEarly": true }, "'{0}' modifier cannot appear on a parameter.": { "category": "Error", "code": 1090, - "isEarly": true + "isEarly": true }, "Only a single variable declaration is allowed in a 'for...in' statement.": { "category": "Error", "code": 1091, - "isEarly": true + "isEarly": true }, "Type parameters cannot appear on a constructor declaration.": { "category": "Error", "code": 1092, - "isEarly": true + "isEarly": true }, "Type annotation cannot appear on a constructor declaration.": { "category": "Error", "code": 1093, - "isEarly": true + "isEarly": true }, "An accessor cannot have type parameters.": { "category": "Error", "code": 1094, - "isEarly": true + "isEarly": true }, "A 'set' accessor cannot have a return type annotation.": { "category": "Error", "code": 1095, - "isEarly": true + "isEarly": true }, "An index signature must have exactly one parameter.": { "category": "Error", "code": 1096, - "isEarly": true + "isEarly": true }, "'{0}' list cannot be empty.": { "category": "Error", "code": 1097, - "isEarly": true + "isEarly": true }, "Type parameter list cannot be empty.": { "category": "Error", "code": 1098, - "isEarly": true + "isEarly": true }, "Type argument list cannot be empty.": { "category": "Error", "code": 1099, - "isEarly": true + "isEarly": true }, "Invalid use of '{0}' in strict mode.": { "category": "Error", "code": 1100, - "isEarly": true + "isEarly": true }, "'with' statements are not allowed in strict mode.": { "category": "Error", "code": 1101, - "isEarly": true + "isEarly": true }, "'delete' cannot be called on an identifier in strict mode.": { "category": "Error", "code": 1102, - "isEarly": true + "isEarly": true }, "A 'continue' statement can only be used within an enclosing iteration statement.": { "category": "Error", "code": 1104, - "isEarly": true + "isEarly": true }, "A 'break' statement can only be used within an enclosing iteration or switch statement.": { "category": "Error", "code": 1105, - "isEarly": true + "isEarly": true }, "Jump target cannot cross function boundary.": { "category": "Error", "code": 1107, - "isEarly": true + "isEarly": true }, "A 'return' statement can only be used within a function body.": { "category": "Error", "code": 1108, - "isEarly": true + "isEarly": true }, "Expression expected.": { "category": "Error", "code": 1109, - "isEarly": true + "isEarly": true }, "Type expected.": { "category": "Error", @@ -347,67 +347,67 @@ "A constructor implementation cannot be declared in an ambient context.": { "category": "Error", "code": 1111, - "isEarly": true + "isEarly": true }, "A class member cannot be declared optional.": { "category": "Error", "code": 1112, - "isEarly": true + "isEarly": true }, "A 'default' clause cannot appear more than once in a 'switch' statement.": { "category": "Error", "code": 1113, - "isEarly": true + "isEarly": true }, "Duplicate label '{0}'": { "category": "Error", "code": 1114, - "isEarly": true + "isEarly": true }, "A 'continue' statement can only jump to a label of an enclosing iteration statement.": { "category": "Error", "code": 1115, - "isEarly": true + "isEarly": true }, "A 'break' statement can only jump to a label of an enclosing statement.": { "category": "Error", "code": 1116, - "isEarly": true + "isEarly": true }, "An object literal cannot have multiple properties with the same name in strict mode.": { "category": "Error", "code": 1117, - "isEarly": true + "isEarly": true }, "An object literal cannot have multiple get/set accessors with the same name.": { "category": "Error", "code": 1118, - "isEarly": true + "isEarly": true }, "An object literal cannot have property and accessor with the same name.": { "category": "Error", "code": 1119, - "isEarly": true + "isEarly": true }, "An export assignment cannot have modifiers.": { "category": "Error", "code": 1120, - "isEarly": true + "isEarly": true }, "Octal literals are not allowed in strict mode.": { "category": "Error", "code": 1121, - "isEarly": true + "isEarly": true }, "A tuple type element list cannot be empty.": { "category": "Error", "code": 1122, - "isEarly": true + "isEarly": true }, "Variable declaration list cannot be empty.": { "category": "Error", "code": 1123, - "isEarly": true + "isEarly": true }, "Digit expected.": { "category": "Error", @@ -456,7 +456,7 @@ "Argument expression expected.": { "category": "Error", "code": 1135, - "isEarly": true + "isEarly": true }, "Property assignment expected.": { "category": "Error", @@ -481,7 +481,7 @@ "String literal expected.": { "category": "Error", "code": 1141, - "isEarly": true + "isEarly": true }, "Line break not permitted here.": { "category": "Error", @@ -495,7 +495,7 @@ "Modifiers not permitted on index signature members.": { "category": "Error", "code": 1145, - "isEarly": true + "isEarly": true }, "Declaration expected.": { "category": "Error", @@ -504,7 +504,7 @@ "Import declarations in an internal module cannot reference an external module.": { "category": "Error", "code": 1147, - "isEarly": true + "isEarly": true }, "Cannot compile external modules unless the '--module' flag is provided.": { "category": "Error", @@ -517,7 +517,7 @@ "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { "category": "Error", "code": 1150, - "isEarly": true + "isEarly": true }, "'var', 'let' or 'const' expected.": { "category": "Error", @@ -526,32 +526,32 @@ "'let' declarations are only available when targeting ECMAScript 6 and higher.": { "category": "Error", "code": 1153, - "isEarly": true + "isEarly": true }, "'const' declarations are only available when targeting ECMAScript 6 and higher.": { "category": "Error", "code": 1154, - "isEarly": true + "isEarly": true }, "'const' declarations must be initialized": { "category": "Error", "code": 1155, - "isEarly": true + "isEarly": true }, "'const' declarations can only be declared inside a block.": { "category": "Error", "code": 1156, - "isEarly": true + "isEarly": true }, "'let' declarations can only be declared inside a block.": { "category": "Error", "code": 1157, - "isEarly": true + "isEarly": true }, "Tagged templates are only available when targeting ECMAScript 6 and higher.": { "category": "Error", "code": 1159, - "isEarly": true + "isEarly": true }, "Unterminated template literal.": { "category": "Error", @@ -564,48 +564,47 @@ "An object member cannot be declared optional.": { "category": "Error", "code": 1162, - "isEarly": true + "isEarly": true }, - "'yield' expression must be contained_within a generator declaration." - : { + "'yield' expression must be contained_within a generator declaration.": { "category": "Error", "code": 1163, - "isEarly": true + "isEarly": true }, "Computed property names are not allowed in enums.": { "category": "Error", "code": 1164, - "isEarly": true + "isEarly": true }, "Computed property names are not allowed in an ambient context.": { "category": "Error", "code": 1165, - "isEarly": true + "isEarly": true }, "Computed property names are not allowed in class property declarations.": { "category": "Error", "code": 1166, - "isEarly": true + "isEarly": true }, "Computed property names are only available when targeting ECMAScript 6 and higher.": { "category": "Error", "code": 1167, - "isEarly": true + "isEarly": true }, "Computed property names are not allowed in method overloads.": { "category": "Error", "code": 1168, - "isEarly": true + "isEarly": true }, "Computed property names are not allowed in interfaces.": { "category": "Error", "code": 1169, - "isEarly": true + "isEarly": true }, "Computed property names are not allowed in type literals.": { "category": "Error", "code": 1170, - "isEarly": true + "isEarly": true }, "A comma expression is not allowed in a computed property name.": { "category": "Error", @@ -614,27 +613,27 @@ "'extends' clause already seen.": { "category": "Error", "code": 1172, - "isEarly": true + "isEarly": true }, "'extends' clause must precede 'implements' clause.": { "category": "Error", "code": 1173, - "isEarly": true + "isEarly": true }, "Classes can only extend a single class.": { "category": "Error", "code": 1174, - "isEarly": true + "isEarly": true }, "'implements' clause already seen.": { "category": "Error", "code": 1175, - "isEarly": true + "isEarly": true }, "Interface declaration cannot have 'implements' clause.": { "category": "Error", "code": 1176, - "isEarly": true + "isEarly": true }, "Binary digit expected.": { "category": "Error", @@ -659,11 +658,16 @@ "A destructuring declaration must have an initializer.": { "category": "Error", "code": 1182, - "isEarly": true + "isEarly": true }, "Destructuring declarations are not allowed in ambient contexts.": { "category": "Error", "code": 1183, + "isEarly": true + }, + "An implementation cannot be declared in ambient contexts.": { + "category": "Error", + "code": 1184, "isEarly": true }, diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 49871d790a2..ebd1d9d31c4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4625,7 +4625,7 @@ module ts { function checkNode(node: Node, nodeKind: SyntaxKind): boolean { // Now do node specific checks. - switch (nodeKind) { + //switch (nodeKind) { //case SyntaxKind.BreakStatement: //case SyntaxKind.ContinueStatement: //return checkBreakOrContinueStatement(node); @@ -4667,7 +4667,7 @@ module ts { //return checkProperty(node); //case SyntaxKind.ReturnStatement: return checkReturnStatement(node); //case SyntaxKind.SetAccessor: return checkSetAccessor(node); - case SyntaxKind.SourceFile: return checkSourceFile(node); + //case SyntaxKind.SourceFile: return checkSourceFile(node); //case SyntaxKind.ShorthandPropertyAssignment: return checkShorthandPropertyAssignment(node); //case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); //case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); @@ -4677,7 +4677,9 @@ module ts { //case SyntaxKind.VariableStatement: return checkVariableStatement(node); //case SyntaxKind.WithStatement: return checkWithStatement(node); //case SyntaxKind.YieldExpression: return checkYieldExpression(node); - } + //return false + //} + return false; } function scanToken(pos: number) { @@ -4721,23 +4723,23 @@ module ts { function checkForStatementInAmbientContext(node: Node, kind: SyntaxKind): boolean { switch (kind) { - case SyntaxKind.Block: + //case SyntaxKind.Block: case SyntaxKind.EmptyStatement: - case SyntaxKind.IfStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ContinueStatement: - case SyntaxKind.BreakStatement: - case SyntaxKind.ReturnStatement: - case SyntaxKind.WithStatement: - case SyntaxKind.SwitchStatement: - case SyntaxKind.ThrowStatement: - case SyntaxKind.TryStatement: + //case SyntaxKind.IfStatement: + //case SyntaxKind.DoStatement: + //case SyntaxKind.WhileStatement: + //case SyntaxKind.ForStatement: + //case SyntaxKind.ForInStatement: + //case SyntaxKind.ContinueStatement: + //case SyntaxKind.BreakStatement: + //case SyntaxKind.ReturnStatement: + //case SyntaxKind.WithStatement: + //case SyntaxKind.SwitchStatement: + //case SyntaxKind.ThrowStatement: + //case SyntaxKind.TryStatement: case SyntaxKind.DebuggerStatement: - case SyntaxKind.LabeledStatement: - case SyntaxKind.ExpressionStatement: + //case SyntaxKind.LabeledStatement: + //case SyntaxKind.ExpressionStatement: return grammarErrorOnFirstToken(node, Diagnostics.Statements_are_not_allowed_in_ambient_contexts); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 19baf052406..a733adefce9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1214,6 +1214,7 @@ module ts { isVisible?: boolean; // Is this node visible localModuleName?: string; // Local name for module instance assignmentChecks?: Map; // Cache of assignment checks + hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context } export const enum TypeFlags { diff --git a/tests/baselines/reference/ambientErrors.errors.txt b/tests/baselines/reference/ambientErrors.errors.txt index 834c35e541c..609229bf2f0 100644 --- a/tests/baselines/reference/ambientErrors.errors.txt +++ b/tests/baselines/reference/ambientErrors.errors.txt @@ -1,22 +1,24 @@ tests/cases/conformance/ambient/ambientErrors.ts(2,15): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/ambient/ambientErrors.ts(6,1): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. +tests/cases/conformance/ambient/ambientErrors.ts(17,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1036: Statements are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/conformance/ambient/ambientErrors.ts(24,5): error TS1066: Ambient enum elements can only have integer literal initializers. +tests/cases/conformance/ambient/ambientErrors.ts(29,5): error TS1066: Ambient enum elements can only have integer literal initializers. tests/cases/conformance/ambient/ambientErrors.ts(34,11): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1036: Statements are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/conformance/ambient/ambientErrors.ts(37,20): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(38,13): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(39,23): error TS1111: A constructor implementation cannot be declared in an ambient context. tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/conformance/ambient/ambientErrors.ts(6,1): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. -tests/cases/conformance/ambient/ambientErrors.ts(17,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/ambient/ambientErrors.ts(24,5): error TS1066: Ambient enum elements can only have integer literal initializers. -tests/cases/conformance/ambient/ambientErrors.ts(29,5): error TS1066: Ambient enum elements can only have integer literal initializers. tests/cases/conformance/ambient/ambientErrors.ts(47,20): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/conformance/ambient/ambientErrors.ts(51,16): error TS2436: Ambient external module declaration cannot specify relative module name. tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== tests/cases/conformance/ambient/ambientErrors.ts (16 errors) ==== +==== tests/cases/conformance/ambient/ambientErrors.ts (18 errors) ==== // Ambient variable with an initializer declare var x = 4; ~ @@ -44,6 +46,8 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export // Ambient function with function body declare function fn4() { }; ~ +!!! error TS1036: Statements are not allowed in ambient contexts. + ~ !!! error TS1037: A function implementation cannot be declared in an ambient context. // Ambient enum with non - integer literal constant member @@ -67,6 +71,8 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export !!! error TS1039: Initializers are not allowed in ambient contexts. function fn() { } ~ +!!! error TS1036: Statements are not allowed in ambient contexts. + ~ !!! error TS1037: A function implementation cannot be declared in an ambient context. class C { static x = 3; From fdfd8d486352b557701122cd195a125ebc6fa906 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 16 Dec 2014 19:11:07 -0800 Subject: [PATCH 70/74] Cleaning up migrating grammar checking --- src/compiler/checker.ts | 43 ++- src/compiler/parser.ts | 1 + .../FunctionDeclaration7_es6.errors.txt | 5 +- .../FunctionDeclaration9_es6.errors.txt | 5 +- ...unctionPropertyAssignments5_es6.errors.txt | 6 +- .../MemberFunctionDeclaration3_es6.errors.txt | 5 +- .../VariableDeclaration2_es6.errors.txt | 7 +- .../VariableDeclaration4_es6.errors.txt | 7 +- .../YieldExpression10_es6.errors.txt | 5 +- .../YieldExpression11_es6.errors.txt | 5 +- .../YieldExpression13_es6.errors.txt | 7 +- .../YieldExpression16_es6.errors.txt | 5 +- .../YieldExpression17_es6.errors.txt | 7 +- .../YieldExpression19_es6.errors.txt | 8 +- .../reference/YieldExpression3_es6.errors.txt | 8 +- .../reference/YieldExpression4_es6.errors.txt | 8 +- .../reference/YieldExpression6_es6.errors.txt | 5 +- .../reference/YieldExpression7_es6.errors.txt | 5 +- .../reference/YieldExpression8_es6.errors.txt | 9 +- .../reference/YieldExpression9_es6.errors.txt | 5 +- .../reference/ambientErrors.errors.txt | 23 +- .../ambientWithStatements.errors.txt | 45 +-- .../reference/badArraySyntax.errors.txt | 5 +- ...omputedPropertyNamesOnOverloads.errors.txt | 8 +- ...nstDeclarations-invalidContexts.errors.txt | 5 +- .../constructorOverloads6.errors.txt | 4 +- .../reference/exportAlreadySeen.errors.txt | 14 +- tests/baselines/reference/giant.errors.txt | 270 ++++-------------- .../initializersInDeclarations.errors.txt | 2 +- .../invalidDoWhileBreakStatements.errors.txt | 4 +- ...nvalidDoWhileContinueStatements.errors.txt | 4 +- .../invalidForBreakStatements.errors.txt | 4 +- .../invalidForContinueStatements.errors.txt | 4 +- .../invalidForInBreakStatements.errors.txt | 4 +- .../invalidForInContinueStatements.errors.txt | 4 +- .../invalidWhileBreakStatements.errors.txt | 4 +- .../invalidWhileContinueStatements.errors.txt | 4 +- ...letDeclarations-invalidContexts.errors.txt | 5 +- .../missingRequiredDeclare.d.errors.txt | 7 +- .../reference/newOperator.errors.txt | 5 +- .../objectLiteralGettersAndSetters.errors.txt | 4 +- .../reference/parser618973.errors.txt | 6 +- .../parserBreakStatement1.d.errors.txt | 7 +- .../parserClassDeclaration18.errors.txt | 4 +- .../parserComputedPropertyName11.errors.txt | 5 +- .../parserComputedPropertyName14.errors.txt | 7 +- .../parserComputedPropertyName18.errors.txt | 7 +- .../parserComputedPropertyName20.errors.txt | 5 +- .../parserComputedPropertyName23.errors.txt | 5 +- .../parserComputedPropertyName32.errors.txt | 5 +- .../parserConstructorDeclaration11.errors.txt | 5 +- .../parserConstructorDeclaration12.errors.txt | 26 +- .../parserConstructorDeclaration4.errors.txt | 5 +- .../parserContinueStatement1.d.errors.txt | 7 +- ...parserES5ComputedPropertyName11.errors.txt | 5 +- .../parserFunctionDeclaration2.d.errors.txt | 5 +- .../parserFunctionDeclaration2.errors.txt | 4 +- ...arserMemberFunctionDeclaration5.errors.txt | 5 +- .../parserModuleDeclaration4.d.errors.txt | 5 +- .../parserReturnStatement1.d.errors.txt | 7 +- .../parserVariableStatement1.d.errors.txt | 7 +- .../reference/parserWithStatement2.errors.txt | 7 +- .../reference/parserWithStatement2.js | 7 + .../semicolonsInModuleDeclarations.errors.txt | 5 +- ...hStatementsWithMultipleDefaults.errors.txt | 5 +- ...tringsWithIncompatibleTypedTags.errors.txt | 11 +- ...mplateStringsWithTagsTypedAsAny.errors.txt | 8 +- ...gedTemplateStringsWithTypedTags.errors.txt | 8 +- .../templateStringInYieldKeyword.errors.txt | 5 +- ...ringWithEmbeddedYieldKeywordES6.errors.txt | 5 +- .../reference/yieldExpression1.errors.txt | 5 +- 71 files changed, 388 insertions(+), 395 deletions(-) create mode 100644 tests/baselines/reference/parserWithStatement2.js diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cbdab2e0c11..633d1a8299d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7225,13 +7225,13 @@ module ts { function checkMethodDeclaration(node: MethodDeclaration) { // Grammar checking - // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkGrammarMethod(node); if (node.name.kind === SyntaxKind.ComputedPropertyName) { checkGrammarComputedPropertyName(node.name); } + // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); } @@ -7239,7 +7239,7 @@ module ts { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. checkSignatureDeclaration(node); // Grammar check for checking only related to constructoDeclaration - checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node) || checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ true); + checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); @@ -7764,7 +7764,7 @@ module ts { // Grammar Checking, check signature of function declaration as checkFunctionLikeDeclaration call checkGarmmarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); //Grammar check other component of the functionDeclaration - checkGrammarFunctionName(node.name) || checkGrammarForBodyInAmbientContext(node.body, /*isConstructor*/ false) || checkGrammarForGenerator(node); + checkGrammarFunctionName(node.name) || checkGrammarForGenerator(node); if (fullTypeCheck) { checkCollisionWithCapturedSuperVariable(node, node.name); @@ -8220,12 +8220,6 @@ module ts { if (node.parserContextFlags & ParserContextFlags.StrictMode) { grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); } - else { - // Grammar checking for invalid use of return statement - forEachReturnStatement(node.statement, returnStatement => { - grammarErrorOnFirstToken(returnStatement, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); - }); - } checkExpression(node.expression); error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); @@ -8669,6 +8663,9 @@ module ts { } function checkTypeAliasDeclaration(node: TypeAliasDeclaration) { + // Grammar checking + checkGrammarModifiers(node); + checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0); checkSourceElement(node.type); } @@ -8959,6 +8956,9 @@ module ts { } function checkImportDeclaration(node: ImportDeclaration) { + // Grammar checking + checkGrammarModifiers(node); + checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); var symbol = getSymbolOfNode(node); @@ -9025,6 +9025,8 @@ module ts { function checkExportAssignment(node: ExportAssignment) { // Grammar checking + checkGrammarModifiers(node); + if (node.flags & NodeFlags.Modifier) { grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers); } @@ -9222,11 +9224,11 @@ module ts { // Fully type check a source file and collect the relevant diagnostics. function checkSourceFile(node: SourceFile) { - // Grammar checking - checkGrammarSourceFile(node); - var links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { + // Grammar checking + checkGrammarSourceFile(node); + emitExtends = false; potentialThisCollisions.length = 0; @@ -10359,6 +10361,10 @@ module ts { if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop,(prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); + if (name.kind === SyntaxKind.NumericLiteral) { + } + else if (name.kind === SyntaxKind.StringLiteral) { + } currentKind = Property; } else if ( prop.kind === SyntaxKind.MethodDeclaration) { @@ -10734,7 +10740,7 @@ module ts { var diagnostic = isConstructor ? Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; - return grammarErrorOnFirstToken(body, diagnostic); + return getNodeLinks(body).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(body, diagnostic); } } @@ -10800,9 +10806,16 @@ module ts { function checkGrammarForStatementInAmbientContext(node: Node): void { if (isInAmbientContext(node)) { + // An accessors is already reported about the ambient context + if (isAccessor(node.parent.kind)) { + getNodeLinks(node).hasReportedStatementInAmbientContext = true; + return; + } + // Find containing block which is either Block, ModuleBlock, SourceFile - if (isAnyFunction(node.parent)) { - grammarErrorOnFirstToken(node, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts) + var links = getNodeLinks(node); + if (!links.hasReportedStatementInAmbientContext && isAnyFunction(node.parent)) { + getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts) return; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3549afe5ef4..d2e8000a2fd 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3988,6 +3988,7 @@ module ts { } function checkGrammar(sourceText: string, languageVersion: ScriptTarget, file: SourceFile) { + return; var grammarDiagnostics = file.grammarDiagnostics; // Create a scanner so we can find the start of tokens to report errors on. diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt index 71aff1e2488..f129d3fa30b 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -1,13 +1,16 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS9001: Generators are not currently supported. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ==== function*bar() { ~ !!! error TS9001: Generators are not currently supported. // 'yield' here is an identifier, and not a yield expression. function*foo(a = yield) { + ~ +!!! error TS9001: Generators are not currently supported. ~~~~~ !!! error TS2304: Cannot find name 'yield'. } diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt index 8de32cf0a00..8333eceb267 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (2 errors) ==== function * foo() { ~ !!! error TS9001: Generators are not currently supported. var v = { [yield]: foo } + ~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt index 393ede66a60..eff0c79d827 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS9002: Computed property names are not currently supported. ==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (1 errors) ==== var v = { *[foo()]() { } } - ~ -!!! error TS9001: Generators are not currently supported. \ No newline at end of file + ~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt index b43e266e2a5..ef45ee3f9cb 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,5): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (2 errors) ==== class C { *[foo]() { } ~ !!! error TS9001: Generators are not currently supported. + ~~~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration2_es6.errors.txt b/tests/baselines/reference/VariableDeclaration2_es6.errors.txt index 362b68dbb35..1ae59205204 100644 --- a/tests/baselines/reference/VariableDeclaration2_es6.errors.txt +++ b/tests/baselines/reference/VariableDeclaration2_es6.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts(1,7): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts(1,7): error TS1155: 'const' declarations must be initialized -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts (2 errors) ==== const a ~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. + ~ +!!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration4_es6.errors.txt b/tests/baselines/reference/VariableDeclaration4_es6.errors.txt index ae035825312..8bb7692fb5f 100644 --- a/tests/baselines/reference/VariableDeclaration4_es6.errors.txt +++ b/tests/baselines/reference/VariableDeclaration4_es6.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts(1,7): error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts(1,7): error TS1155: 'const' declarations must be initialized -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts (2 errors) ==== const a: number ~ -!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. \ No newline at end of file +!!! error TS1154: 'const' declarations are only available when targeting ECMAScript 6 and higher. + ~ +!!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression10_es6.errors.txt b/tests/baselines/reference/YieldExpression10_es6.errors.txt index 41d6bb5bf24..e0d7ea4ad27 100644 --- a/tests/baselines/reference/YieldExpression10_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression10_es6.errors.txt @@ -1,11 +1,14 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(2,5): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (2 errors) ==== var v = { * foo() { ~ !!! error TS9001: Generators are not currently supported. yield(foo); + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression11_es6.errors.txt b/tests/baselines/reference/YieldExpression11_es6.errors.txt index eea108619bc..3f322a81f2f 100644 --- a/tests/baselines/reference/YieldExpression11_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression11_es6.errors.txt @@ -1,11 +1,14 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,5): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (2 errors) ==== class C { *foo() { ~ !!! error TS9001: Generators are not currently supported. yield(foo); + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression13_es6.errors.txt b/tests/baselines/reference/YieldExpression13_es6.errors.txt index 185fb2f6193..fc2d885d381 100644 --- a/tests/baselines/reference/YieldExpression13_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression13_es6.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,19): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (2 errors) ==== function* foo() { yield } ~ -!!! error TS9001: Generators are not currently supported. \ No newline at end of file +!!! error TS9001: Generators are not currently supported. + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression16_es6.errors.txt b/tests/baselines/reference/YieldExpression16_es6.errors.txt index 54536a7d4fe..c0d2e4c8fc8 100644 --- a/tests/baselines/reference/YieldExpression16_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression16_es6.errors.txt @@ -1,11 +1,14 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: 'yield' expression must be contained_within a generator declaration. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (2 errors) ==== function* foo() { ~ !!! error TS9001: Generators are not currently supported. function bar() { yield foo; + ~~~~~ +!!! error TS1163: 'yield' expression must be contained_within a generator declaration. } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression17_es6.errors.txt b/tests/baselines/reference/YieldExpression17_es6.errors.txt index 38969a9c6fb..b39f47b07f9 100644 --- a/tests/baselines/reference/YieldExpression17_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression17_es6.errors.txt @@ -1,10 +1,13 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. +tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: 'yield' expression must be contained_within a generator declaration. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (3 errors) ==== var v = { get foo() { yield foo; } } ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~ -!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. \ No newline at end of file +!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + ~~~~~ +!!! error TS1163: 'yield' expression must be contained_within a generator declaration. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression19_es6.errors.txt b/tests/baselines/reference/YieldExpression19_es6.errors.txt index 81cf0e2063c..9d04d9559b0 100644 --- a/tests/baselines/reference/YieldExpression19_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression19_es6.errors.txt @@ -1,13 +1,19 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(3,13): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(4,7): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (3 errors) ==== function*foo() { ~ !!! error TS9001: Generators are not currently supported. function bar() { function* quux() { + ~ +!!! error TS9001: Generators are not currently supported. yield(foo); + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } } } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression3_es6.errors.txt b/tests/baselines/reference/YieldExpression3_es6.errors.txt index 91da79fbb53..1e284c92786 100644 --- a/tests/baselines/reference/YieldExpression3_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression3_es6.errors.txt @@ -1,10 +1,16 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (3 errors) ==== function* foo() { ~ !!! error TS9001: Generators are not currently supported. yield + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. yield + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression4_es6.errors.txt b/tests/baselines/reference/YieldExpression4_es6.errors.txt index ca7ed3d354c..2d2a7ca3257 100644 --- a/tests/baselines/reference/YieldExpression4_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression4_es6.errors.txt @@ -1,10 +1,16 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (3 errors) ==== function* foo() { ~ !!! error TS9001: Generators are not currently supported. yield; + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. yield; + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression6_es6.errors.txt b/tests/baselines/reference/YieldExpression6_es6.errors.txt index d8ce78a300f..a3d9481601a 100644 --- a/tests/baselines/reference/YieldExpression6_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression6_es6.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (2 errors) ==== function* foo() { ~ !!! error TS9001: Generators are not currently supported. yield*foo + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression7_es6.errors.txt b/tests/baselines/reference/YieldExpression7_es6.errors.txt index 87b15ac9f71..393a03ee269 100644 --- a/tests/baselines/reference/YieldExpression7_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression7_es6.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (2 errors) ==== function* foo() { ~ !!! error TS9001: Generators are not currently supported. yield foo + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression8_es6.errors.txt b/tests/baselines/reference/YieldExpression8_es6.errors.txt index a32a3bcdc41..3f7933c5bb2 100644 --- a/tests/baselines/reference/YieldExpression8_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression8_es6.errors.txt @@ -1,12 +1,9 @@ -<<<<<<< HEAD -tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS9001: Generators are not currently supported. -======= ->>>>>>> master tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error TS2304: Cannot find name 'yield'. tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (3 errors) ==== yield(foo); ~~~~~ !!! error TS2304: Cannot find name 'yield'. @@ -14,4 +11,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error ~ !!! error TS9001: Generators are not currently supported. yield(foo); + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression9_es6.errors.txt b/tests/baselines/reference/YieldExpression9_es6.errors.txt index ae1b105903a..cd753647327 100644 --- a/tests/baselines/reference/YieldExpression9_es6.errors.txt +++ b/tests/baselines/reference/YieldExpression9_es6.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (1 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (2 errors) ==== var v = function*() { ~ !!! error TS9001: Generators are not currently supported. yield(foo); + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/ambientErrors.errors.txt b/tests/baselines/reference/ambientErrors.errors.txt index 08f6037fcbb..eb06b785914 100644 --- a/tests/baselines/reference/ambientErrors.errors.txt +++ b/tests/baselines/reference/ambientErrors.errors.txt @@ -1,19 +1,14 @@ tests/cases/conformance/ambient/ambientErrors.ts(2,15): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(6,1): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/conformance/ambient/ambientErrors.ts(17,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -<<<<<<< HEAD -tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1036: Statements are not allowed in ambient contexts. -======= ->>>>>>> master -tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(24,5): error TS1066: Ambient enum elements can only have integer literal initializers. tests/cases/conformance/ambient/ambientErrors.ts(29,5): error TS1066: Ambient enum elements can only have integer literal initializers. tests/cases/conformance/ambient/ambientErrors.ts(34,11): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(37,20): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(38,13): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/conformance/ambient/ambientErrors.ts(39,23): error TS1111: A constructor implementation cannot be declared in an ambient context. +tests/cases/conformance/ambient/ambientErrors.ts(39,23): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/conformance/ambient/ambientErrors.ts(47,20): error TS2435: Ambient external modules cannot be nested in other modules. @@ -21,7 +16,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(51,16): error TS2436: Ambient e tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== tests/cases/conformance/ambient/ambientErrors.ts (18 errors) ==== +==== tests/cases/conformance/ambient/ambientErrors.ts (16 errors) ==== // Ambient variable with an initializer declare var x = 4; ~ @@ -49,9 +44,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export // Ambient function with function body declare function fn4() { }; ~ -!!! error TS1036: Statements are not allowed in ambient contexts. - ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. // Ambient enum with non - integer literal constant member declare enum E1 { @@ -74,9 +67,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export !!! error TS1039: Initializers are not allowed in ambient contexts. function fn() { } ~ -!!! error TS1036: Statements are not allowed in ambient contexts. - ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. class C { static x = 3; ~ @@ -86,7 +77,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export !!! error TS1039: Initializers are not allowed in ambient contexts. constructor() { } ~ -!!! error TS1111: A constructor implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. fn() { } ~ !!! error TS1037: A function implementation cannot be declared in an ambient context. diff --git a/tests/baselines/reference/ambientWithStatements.errors.txt b/tests/baselines/reference/ambientWithStatements.errors.txt index 2b592feb775..2179b3efb04 100644 --- a/tests/baselines/reference/ambientWithStatements.errors.txt +++ b/tests/baselines/reference/ambientWithStatements.errors.txt @@ -1,74 +1,47 @@ tests/cases/compiler/ambientWithStatements.ts(2,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(3,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(4,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(5,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(7,5): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/compiler/ambientWithStatements.ts(2,5): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. +tests/cases/compiler/ambientWithStatements.ts(3,5): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. tests/cases/compiler/ambientWithStatements.ts(7,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. -tests/cases/compiler/ambientWithStatements.ts(8,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(9,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(10,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(11,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(12,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(18,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(19,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(25,5): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/compiler/ambientWithStatements.ts(11,5): error TS1108: A 'return' statement can only be used within a function body. tests/cases/compiler/ambientWithStatements.ts(25,11): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -==== tests/cases/compiler/ambientWithStatements.ts (15 errors) ==== +==== tests/cases/compiler/ambientWithStatements.ts (6 errors) ==== declare module M { break; ~~~~~ !!! error TS1036: Statements are not allowed in ambient contexts. + ~~~~~~ +!!! error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. continue; - ~~~~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. + ~~~~~~~~~ +!!! error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. debugger; - ~~~~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. do { } while (true); - ~~ -!!! error TS1036: Statements are not allowed in ambient contexts. var x; for (x in null) { } - ~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. ~~~~ !!! error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. if (true) { } else { } - ~~ -!!! error TS1036: Statements are not allowed in ambient contexts. 1; - ~ -!!! error TS1036: Statements are not allowed in ambient contexts. L: var y; - ~ -!!! error TS1036: Statements are not allowed in ambient contexts. return; ~~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. +!!! error TS1108: A 'return' statement can only be used within a function body. switch (x) { - ~~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. case 1: break; default: break; } throw "nooo"; - ~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. try { - ~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. } catch (e) { } finally { } with (x) { - ~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. ~ !!! error TS2410: All symbols within a 'with' block will be resolved to 'any'. } diff --git a/tests/baselines/reference/badArraySyntax.errors.txt b/tests/baselines/reference/badArraySyntax.errors.txt index b22097253fc..3c6b28408f2 100644 --- a/tests/baselines/reference/badArraySyntax.errors.txt +++ b/tests/baselines/reference/badArraySyntax.errors.txt @@ -2,10 +2,11 @@ tests/cases/compiler/badArraySyntax.ts(6,15): error TS1150: 'new T[]' cannot be tests/cases/compiler/badArraySyntax.ts(7,15): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/badArraySyntax.ts(8,20): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/compiler/badArraySyntax.ts(9,20): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. +tests/cases/compiler/badArraySyntax.ts(10,36): error TS1109: Expression expected. tests/cases/compiler/badArraySyntax.ts(10,40): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -==== tests/cases/compiler/badArraySyntax.ts (5 errors) ==== +==== tests/cases/compiler/badArraySyntax.ts (6 errors) ==== class Z { public x = ""; } @@ -24,6 +25,8 @@ tests/cases/compiler/badArraySyntax.ts(10,40): error TS1150: 'new T[]' cannot be ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. var a6: Z[][] = new Z [ ] [ ]; + ~ +!!! error TS1109: Expression expected. ~~~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt index 6329ab39f0f..edd7a19a957 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt @@ -1,18 +1,24 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(4,5): error TS1168: Computed property names are not allowed in method overloads. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(4,5): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(5,5): error TS1168: Computed property names are not allowed in method overloads. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(5,5): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(6,5): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (3 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (5 errors) ==== var methodName = "method"; var accessorName = "accessor"; class C { [methodName](v: string); ~~~~~~~~~~~~ !!! error TS1168: Computed property names are not allowed in method overloads. + ~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. [methodName](); ~~~~~~~~~~~~ !!! error TS1168: Computed property names are not allowed in method overloads. + ~~~~~~~~~~~~ +!!! error TS9002: Computed property names are not currently supported. [methodName](v?: string) { } ~~~~~~~~~~~~ !!! error TS9002: Computed property names are not currently supported. diff --git a/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt b/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt index 930f2d8d813..87378cffe4d 100644 --- a/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt +++ b/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt @@ -3,14 +3,13 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(6,5): error TS1156: 'c tests/cases/compiler/constDeclarations-invalidContexts.ts(9,5): error TS1156: 'const' declarations can only be declared inside a block. tests/cases/compiler/constDeclarations-invalidContexts.ts(12,5): error TS1156: 'const' declarations can only be declared inside a block. tests/cases/compiler/constDeclarations-invalidContexts.ts(16,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -tests/cases/compiler/constDeclarations-invalidContexts.ts(17,5): error TS1156: 'const' declarations can only be declared inside a block. tests/cases/compiler/constDeclarations-invalidContexts.ts(20,5): error TS1156: 'const' declarations can only be declared inside a block. tests/cases/compiler/constDeclarations-invalidContexts.ts(23,5): error TS1156: 'const' declarations can only be declared inside a block. tests/cases/compiler/constDeclarations-invalidContexts.ts(26,12): error TS1156: 'const' declarations can only be declared inside a block. tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: 'const' declarations can only be declared inside a block. -==== tests/cases/compiler/constDeclarations-invalidContexts.ts (10 errors) ==== +==== tests/cases/compiler/constDeclarations-invalidContexts.ts (9 errors) ==== // Errors, const must be defined inside a block if (true) @@ -38,8 +37,6 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: ~~~ !!! error TS2410: All symbols within a 'with' block will be resolved to 'any'. const c5 = 0; - ~~~~~~~~~~~~~ -!!! error TS1156: 'const' declarations can only be declared inside a block. for (var i = 0; i < 10; i++) const c6 = 0; diff --git a/tests/baselines/reference/constructorOverloads6.errors.txt b/tests/baselines/reference/constructorOverloads6.errors.txt index d5cf2486fe1..65827007a8e 100644 --- a/tests/baselines/reference/constructorOverloads6.errors.txt +++ b/tests/baselines/reference/constructorOverloads6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/constructorOverloads6.ts(4,25): error TS1111: A constructor implementation cannot be declared in an ambient context. +tests/cases/compiler/constructorOverloads6.ts(4,25): error TS1184: An implementation cannot be declared in ambient contexts. ==== tests/cases/compiler/constructorOverloads6.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/constructorOverloads6.ts(4,25): error TS1111: A constructor constructor(n: number); constructor(x: any) { ~ -!!! error TS1111: A constructor implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. } bar1():void; diff --git a/tests/baselines/reference/exportAlreadySeen.errors.txt b/tests/baselines/reference/exportAlreadySeen.errors.txt index 707b34c8d25..eb9f0ce1a95 100644 --- a/tests/baselines/reference/exportAlreadySeen.errors.txt +++ b/tests/baselines/reference/exportAlreadySeen.errors.txt @@ -1,12 +1,16 @@ tests/cases/compiler/exportAlreadySeen.ts(2,12): error TS1030: 'export' modifier already seen. tests/cases/compiler/exportAlreadySeen.ts(3,12): error TS1030: 'export' modifier already seen. tests/cases/compiler/exportAlreadySeen.ts(5,12): error TS1030: 'export' modifier already seen. +tests/cases/compiler/exportAlreadySeen.ts(6,16): error TS1030: 'export' modifier already seen. +tests/cases/compiler/exportAlreadySeen.ts(7,16): error TS1030: 'export' modifier already seen. tests/cases/compiler/exportAlreadySeen.ts(12,12): error TS1030: 'export' modifier already seen. tests/cases/compiler/exportAlreadySeen.ts(13,12): error TS1030: 'export' modifier already seen. tests/cases/compiler/exportAlreadySeen.ts(15,12): error TS1030: 'export' modifier already seen. +tests/cases/compiler/exportAlreadySeen.ts(16,16): error TS1030: 'export' modifier already seen. +tests/cases/compiler/exportAlreadySeen.ts(17,16): error TS1030: 'export' modifier already seen. -==== tests/cases/compiler/exportAlreadySeen.ts (6 errors) ==== +==== tests/cases/compiler/exportAlreadySeen.ts (10 errors) ==== module M { export export var x = 1; ~~~~~~ @@ -19,7 +23,11 @@ tests/cases/compiler/exportAlreadySeen.ts(15,12): error TS1030: 'export' modifie ~~~~~~ !!! error TS1030: 'export' modifier already seen. export export class C { } + ~~~~~~ +!!! error TS1030: 'export' modifier already seen. export export interface I { } + ~~~~~~ +!!! error TS1030: 'export' modifier already seen. } } @@ -35,6 +43,10 @@ tests/cases/compiler/exportAlreadySeen.ts(15,12): error TS1030: 'export' modifie ~~~~~~ !!! error TS1030: 'export' modifier already seen. export export class C { } + ~~~~~~ +!!! error TS1030: 'export' modifier already seen. export export interface I { } + ~~~~~~ +!!! error TS1030: 'export' modifier already seen. } } \ No newline at end of file diff --git a/tests/baselines/reference/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index d8239e0027a..5a356ab6f2a 100644 --- a/tests/baselines/reference/giant.errors.txt +++ b/tests/baselines/reference/giant.errors.txt @@ -17,13 +17,10 @@ tests/cases/compiler/giant.ts(35,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(36,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(61,5): error TS1169: Computed property names are not allowed in interfaces. -<<<<<<< HEAD -======= tests/cases/compiler/giant.ts(62,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(63,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(76,5): error TS2386: Overload signatures must all be optional or required. tests/cases/compiler/giant.ts(87,16): error TS2300: Duplicate identifier 'pgF'. ->>>>>>> master tests/cases/compiler/giant.ts(88,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(88,20): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(89,16): error TS2300: Duplicate identifier 'psF'. @@ -42,13 +39,10 @@ tests/cases/compiler/giant.ts(99,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(100,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(100,20): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(125,9): error TS1169: Computed property names are not allowed in interfaces. -<<<<<<< HEAD -======= tests/cases/compiler/giant.ts(126,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(127,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(140,9): error TS2386: Overload signatures must all be optional or required. ->>>>>>> master -tests/cases/compiler/giant.ts(154,39): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(154,39): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(166,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(167,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(167,20): error TS2300: Duplicate identifier 'pgF'. @@ -68,15 +62,12 @@ tests/cases/compiler/giant.ts(178,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(179,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(179,20): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(204,9): error TS1169: Computed property names are not allowed in interfaces. -<<<<<<< HEAD -======= tests/cases/compiler/giant.ts(205,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(206,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(219,9): error TS2386: Overload signatures must all be optional or required. ->>>>>>> master -tests/cases/compiler/giant.ts(233,39): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(238,35): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(240,24): error TS1111: A constructor implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(233,39): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(238,35): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(240,24): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(243,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(244,22): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(245,16): error TS2300: Duplicate identifier 'pgF'. @@ -104,10 +95,9 @@ tests/cases/compiler/giant.ts(257,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(257,22): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(258,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(258,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(262,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(262,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(262,25): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(267,30): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(267,33): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/compiler/giant.ts(267,30): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(281,12): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(282,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(282,16): error TS2300: Duplicate identifier 'pgF'. @@ -127,13 +117,10 @@ tests/cases/compiler/giant.ts(293,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(294,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(294,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(319,5): error TS1169: Computed property names are not allowed in interfaces. -<<<<<<< HEAD -======= tests/cases/compiler/giant.ts(320,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(321,6): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(334,5): error TS2386: Overload signatures must all be optional or required. tests/cases/compiler/giant.ts(345,16): error TS2300: Duplicate identifier 'pgF'. ->>>>>>> master tests/cases/compiler/giant.ts(346,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(346,20): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(347,16): error TS2300: Duplicate identifier 'psF'. @@ -152,13 +139,10 @@ tests/cases/compiler/giant.ts(357,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(358,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(358,20): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(383,9): error TS1169: Computed property names are not allowed in interfaces. -<<<<<<< HEAD -======= tests/cases/compiler/giant.ts(384,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(385,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(398,9): error TS2386: Overload signatures must all be optional or required. ->>>>>>> master -tests/cases/compiler/giant.ts(412,39): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(412,39): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(424,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(425,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(425,20): error TS2300: Duplicate identifier 'pgF'. @@ -178,15 +162,12 @@ tests/cases/compiler/giant.ts(436,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(437,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(437,20): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(462,9): error TS1169: Computed property names are not allowed in interfaces. -<<<<<<< HEAD -======= tests/cases/compiler/giant.ts(463,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(464,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(477,9): error TS2386: Overload signatures must all be optional or required. ->>>>>>> master -tests/cases/compiler/giant.ts(491,39): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(496,35): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(498,24): error TS1111: A constructor implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(491,39): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(496,35): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(498,24): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(501,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(502,22): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(503,16): error TS2300: Duplicate identifier 'pgF'. @@ -214,12 +195,11 @@ tests/cases/compiler/giant.ts(515,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(515,22): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(516,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(516,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(520,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(520,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(520,25): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(525,30): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(525,33): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(532,31): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(534,20): error TS1111: A constructor implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(525,30): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(532,31): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(534,20): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(537,17): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(538,18): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(539,12): error TS2300: Duplicate identifier 'pgF'. @@ -247,181 +227,37 @@ tests/cases/compiler/giant.ts(551,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(551,18): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(552,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(552,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(556,18): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(556,18): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(556,21): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(558,24): error TS1111: A constructor implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(558,24): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(561,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(563,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(587,9): error TS1169: Computed property names are not allowed in interfaces. -<<<<<<< HEAD -======= tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(602,9): error TS2386: Overload signatures must all be optional or required. ->>>>>>> master -tests/cases/compiler/giant.ts(606,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(606,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(606,25): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(611,30): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(611,33): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/compiler/giant.ts(611,30): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(615,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/giant.ts(616,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -tests/cases/compiler/giant.ts(616,42): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/compiler/giant.ts(616,39): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(617,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/giant.ts(618,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -tests/cases/compiler/giant.ts(621,26): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(621,29): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(623,24): error TS1111: A constructor implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(621,26): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(623,24): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(626,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(628,21): error TS1037: A function implementation cannot be declared in an ambient context. tests/cases/compiler/giant.ts(653,9): error TS1169: Computed property names are not allowed in interfaces. -<<<<<<< HEAD -======= tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all be optional or required. ->>>>>>> master -tests/cases/compiler/giant.ts(672,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(672,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(672,25): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(676,30): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(676,33): error TS1036: Statements are not allowed in ambient contexts. -<<<<<<< HEAD -tests/cases/compiler/giant.ts(23,12): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(24,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(25,12): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(26,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(27,13): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(28,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(29,13): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(30,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(33,12): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(34,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(35,12): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(36,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(62,5): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(63,6): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/giant.ts(76,5): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(87,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(88,20): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(89,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(90,20): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(91,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(92,21): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(93,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(94,21): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(97,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(98,20): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(99,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(100,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(126,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(127,10): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/giant.ts(140,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(166,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(167,20): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(168,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(169,20): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(170,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(171,21): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(172,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(173,21): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(176,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(177,20): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(178,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(179,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(205,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(206,10): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/giant.ts(219,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(245,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(246,20): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(247,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(248,20): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(249,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(250,21): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(251,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(252,21): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(255,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(256,20): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(257,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(258,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(281,12): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(282,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(283,12): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(284,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(285,13): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(286,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(287,13): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(288,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(291,12): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(292,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(293,12): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(294,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(320,5): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(321,6): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/giant.ts(334,5): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(345,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(346,20): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(347,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(348,20): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(349,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(350,21): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(351,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(352,21): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(355,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(356,20): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(357,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(358,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(384,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(385,10): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/giant.ts(398,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(424,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(425,20): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(426,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(427,20): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(428,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(429,21): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(430,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(431,21): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(434,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(435,20): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(436,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(437,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(463,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(464,10): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/giant.ts(477,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(503,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(504,20): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(505,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(506,20): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(507,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(508,21): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(509,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(510,21): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(513,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(514,20): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(515,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(516,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(539,12): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(540,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(541,12): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(542,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(543,13): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(544,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(545,13): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(546,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(549,12): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(550,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(551,12): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(552,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/giant.ts(602,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter. -tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all be optional or required. -======= ->>>>>>> master +tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be declared in ambient contexts. -==== tests/cases/compiler/giant.ts (262 errors) ==== +==== tests/cases/compiler/giant.ts (257 errors) ==== /* Prefixes @@ -665,7 +501,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export declare class eaC { }; export declare module eaM { }; } @@ -790,18 +626,18 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export declare class eaC { }; export declare module eaM { }; } export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export declare class eaC { constructor () { } ~ -!!! error TS1111: A constructor implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public pV; private rV; public pF() { } @@ -879,7 +715,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all var V; function F() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. ~ !!! error TS1036: Statements are not allowed in ambient contexts. class C { } @@ -888,9 +724,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export var eV; export function eF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. - ~ -!!! error TS1036: Statements are not allowed in ambient contexts. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export class eC { } export interface eI { } export module eM { } @@ -1125,7 +959,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export declare class eaC { }; export declare module eaM { }; } @@ -1250,18 +1084,18 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export declare class eaC { }; export declare module eaM { }; } export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export declare class eaC { constructor () { } ~ -!!! error TS1111: A constructor implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public pV; private rV; public pF() { } @@ -1339,7 +1173,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all var V; function F() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. ~ !!! error TS1036: Statements are not allowed in ambient contexts. class C { } @@ -1348,9 +1182,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export var eV; export function eF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. - ~ -!!! error TS1036: Statements are not allowed in ambient contexts. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export class eC { } export interface eI { } export module eM { } @@ -1359,11 +1191,11 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export declare class eaC { constructor () { } ~ -!!! error TS1111: A constructor implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public pV; private rV; public pF() { } @@ -1441,13 +1273,13 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all var V; function F() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. ~ !!! error TS1036: Statements are not allowed in ambient contexts. class C { constructor () { } ~ -!!! error TS1111: A constructor implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public pV; private rV; public pF() { } @@ -1509,7 +1341,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all var V; function F() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. ~ !!! error TS1036: Statements are not allowed in ambient contexts. class C { } @@ -1518,9 +1350,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export var eV; export function eF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. - ~ -!!! error TS1036: Statements are not allowed in ambient contexts. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export class eC { } export interface eI { } export module eM { } @@ -1530,8 +1360,8 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export declare function eaF() { }; ~~~~~~~ !!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. - ~ -!!! error TS1036: Statements are not allowed in ambient contexts. + ~ +!!! error TS1184: An implementation cannot be declared in ambient contexts. export declare class eaC { } ~~~~~~~ !!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. @@ -1542,13 +1372,11 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export var eV; export function eF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. - ~ -!!! error TS1036: Statements are not allowed in ambient contexts. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export class eC { constructor () { } ~ -!!! error TS1111: A constructor implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public pV; private rV; public pF() { } @@ -1611,7 +1439,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all var V; function F() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. ~ !!! error TS1036: Statements are not allowed in ambient contexts. class C { } @@ -1619,9 +1447,7 @@ tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all export var eV; export function eF() { }; ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. - ~ -!!! error TS1036: Statements are not allowed in ambient contexts. +!!! error TS1184: An implementation cannot be declared in ambient contexts. export class eC { } export interface eI { } export module eM { } diff --git a/tests/baselines/reference/initializersInDeclarations.errors.txt b/tests/baselines/reference/initializersInDeclarations.errors.txt index ad92cc79281..5ab9ae5d2bc 100644 --- a/tests/baselines/reference/initializersInDeclarations.errors.txt +++ b/tests/baselines/reference/initializersInDeclarations.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/externalModules/initializersInDeclarations.ts(5,9): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(6,16): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(7,16): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/conformance/externalModules/initializersInDeclarations.ts(16,2): error TS1036: Statements are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(12,15): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(13,15): error TS1039: Initializers are not allowed in ambient contexts. +tests/cases/conformance/externalModules/initializersInDeclarations.ts(16,2): error TS1036: Statements are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(18,16): error TS1039: Initializers are not allowed in ambient contexts. diff --git a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt index 6113009e598..65fd55b763b 100644 --- a/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileBreakStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(8,4): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. ==== tests/cases/conformance/statements/breakStatements/invalidDoWhileBreakStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt index c89f9c01055..e9643394d12 100644 --- a/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidDoWhileContinueStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(8,4): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. ==== tests/cases/conformance/statements/continueStatements/invalidDoWhileContinueStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidForBreakStatements.errors.txt b/tests/baselines/reference/invalidForBreakStatements.errors.txt index c63c97dcf69..50e4013c0ea 100644 --- a/tests/baselines/reference/invalidForBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForBreakStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(8,9): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts(36,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. ==== tests/cases/conformance/statements/breakStatements/invalidForBreakStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidForContinueStatements.errors.txt b/tests/baselines/reference/invalidForContinueStatements.errors.txt index 459c2c5efa7..3af47370df1 100644 --- a/tests/baselines/reference/invalidForContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForContinueStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(8,9): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts(36,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. ==== tests/cases/conformance/statements/continueStatements/invalidForContinueStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidForInBreakStatements.errors.txt b/tests/baselines/reference/invalidForInBreakStatements.errors.txt index c12babd3a3a..d83304ab1c6 100644 --- a/tests/baselines/reference/invalidForInBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidForInBreakStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(8,19): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. ==== tests/cases/conformance/statements/breakStatements/invalidForInBreakStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidForInContinueStatements.errors.txt b/tests/baselines/reference/invalidForInContinueStatements.errors.txt index ebd96fd6e46..7353a22d9cd 100644 --- a/tests/baselines/reference/invalidForInContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidForInContinueStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(8,19): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. ==== tests/cases/conformance/statements/continueStatements/invalidForInContinueStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt index 1ed29772d7b..54adc2856d7 100644 --- a/tests/baselines/reference/invalidWhileBreakStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileBreakStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(4,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(8,14): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(27,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts(37,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. ==== tests/cases/conformance/statements/breakStatements/invalidWhileBreakStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt index ac658dbc944..462b244efd4 100644 --- a/tests/baselines/reference/invalidWhileContinueStatements.errors.txt +++ b/tests/baselines/reference/invalidWhileContinueStatements.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(4,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(8,14): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(14,9): error TS1107: Jump target cannot cross function boundary. tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(21,9): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(27,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts(37,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. ==== tests/cases/conformance/statements/continueStatements/invalidWhileContinueStatements.ts (6 errors) ==== diff --git a/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt b/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt index f8115718b80..1ece1f31433 100644 --- a/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt +++ b/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt @@ -3,14 +3,13 @@ tests/cases/compiler/letDeclarations-invalidContexts.ts(6,5): error TS1157: 'let tests/cases/compiler/letDeclarations-invalidContexts.ts(9,5): error TS1157: 'let' declarations can only be declared inside a block. tests/cases/compiler/letDeclarations-invalidContexts.ts(12,5): error TS1157: 'let' declarations can only be declared inside a block. tests/cases/compiler/letDeclarations-invalidContexts.ts(16,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -tests/cases/compiler/letDeclarations-invalidContexts.ts(17,5): error TS1157: 'let' declarations can only be declared inside a block. tests/cases/compiler/letDeclarations-invalidContexts.ts(20,5): error TS1157: 'let' declarations can only be declared inside a block. tests/cases/compiler/letDeclarations-invalidContexts.ts(23,5): error TS1157: 'let' declarations can only be declared inside a block. tests/cases/compiler/letDeclarations-invalidContexts.ts(26,12): error TS1157: 'let' declarations can only be declared inside a block. tests/cases/compiler/letDeclarations-invalidContexts.ts(29,29): error TS1157: 'let' declarations can only be declared inside a block. -==== tests/cases/compiler/letDeclarations-invalidContexts.ts (10 errors) ==== +==== tests/cases/compiler/letDeclarations-invalidContexts.ts (9 errors) ==== // Errors, let must be defined inside a block if (true) @@ -38,8 +37,6 @@ tests/cases/compiler/letDeclarations-invalidContexts.ts(29,29): error TS1157: 'l ~~~ !!! error TS2410: All symbols within a 'with' block will be resolved to 'any'. let l5 = 0; - ~~~~~~~~~~~ -!!! error TS1157: 'let' declarations can only be declared inside a block. for (var i = 0; i < 10; i++) let l6 = 0; diff --git a/tests/baselines/reference/missingRequiredDeclare.d.errors.txt b/tests/baselines/reference/missingRequiredDeclare.d.errors.txt index 1e52fa92fe5..dc713c86d89 100644 --- a/tests/baselines/reference/missingRequiredDeclare.d.errors.txt +++ b/tests/baselines/reference/missingRequiredDeclare.d.errors.txt @@ -1,7 +1,10 @@ tests/cases/compiler/missingRequiredDeclare.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. +tests/cases/compiler/missingRequiredDeclare.d.ts(1,7): error TS1039: Initializers are not allowed in ambient contexts. -==== tests/cases/compiler/missingRequiredDeclare.d.ts (1 errors) ==== +==== tests/cases/compiler/missingRequiredDeclare.d.ts (2 errors) ==== var x = 1; ~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. \ No newline at end of file +!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. + ~ +!!! error TS1039: Initializers are not allowed in ambient contexts. \ No newline at end of file diff --git a/tests/baselines/reference/newOperator.errors.txt b/tests/baselines/reference/newOperator.errors.txt index 50a25a16a2c..7998217f2e5 100644 --- a/tests/baselines/reference/newOperator.errors.txt +++ b/tests/baselines/reference/newOperator.errors.txt @@ -9,9 +9,10 @@ tests/cases/compiler/newOperator.ts(22,1): error TS1150: 'new T[]' cannot be use tests/cases/compiler/newOperator.ts(28,13): error TS2304: Cannot find name 'q'. tests/cases/compiler/newOperator.ts(31,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/newOperator.ts(44,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/newOperator.ts(45,23): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -==== tests/cases/compiler/newOperator.ts (11 errors) ==== +==== tests/cases/compiler/newOperator.ts (12 errors) ==== interface ifc { } // Attempting to 'new' an interface yields poor error var i = new ifc(); @@ -80,6 +81,8 @@ tests/cases/compiler/newOperator.ts(44,16): error TS1056: Accessors are only ava ~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return new M.T[]; + ~~ +!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. } } \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralGettersAndSetters.errors.txt b/tests/baselines/reference/objectLiteralGettersAndSetters.errors.txt index abc93a9cacc..4e04b856d8c 100644 --- a/tests/baselines/reference/objectLiteralGettersAndSetters.errors.txt +++ b/tests/baselines/reference/objectLiteralGettersAndSetters.errors.txt @@ -22,12 +22,12 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetter tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(37,59): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(38,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(38,60): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(43,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(42,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(43,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(50,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(55,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(64,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(60,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(64,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(67,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(68,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/objectLiterals/objectLiteralGettersAndSetters.ts(76,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/parser618973.errors.txt b/tests/baselines/reference/parser618973.errors.txt index 3aa4abcfd70..83cbfb3eb67 100644 --- a/tests/baselines/reference/parser618973.errors.txt +++ b/tests/baselines/reference/parser618973.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts(1,21): error TS1148: Cannot compile external modules unless the '--module' flag is provided. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts(1,8): error TS1030: 'export' modifier already seen. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts(1,21): error TS1148: Cannot compile external modules unless the '--module' flag is provided. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser618973.ts (2 errors) ==== export export class Foo { - ~~~ -!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. ~~~~~~ !!! error TS1030: 'export' modifier already seen. + ~~~ +!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided. public Bar() { } } \ No newline at end of file diff --git a/tests/baselines/reference/parserBreakStatement1.d.errors.txt b/tests/baselines/reference/parserBreakStatement1.d.errors.txt index a930d5a0124..b6f92ee8388 100644 --- a/tests/baselines/reference/parserBreakStatement1.d.errors.txt +++ b/tests/baselines/reference/parserBreakStatement1.d.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserBreakStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/conformance/parser/ecmascript5/Statements/parserBreakStatement1.d.ts(1,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserBreakStatement1.d.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserBreakStatement1.d.ts (2 errors) ==== break; ~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. \ No newline at end of file +!!! error TS1036: Statements are not allowed in ambient contexts. + ~~~~~~ +!!! error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. \ No newline at end of file diff --git a/tests/baselines/reference/parserClassDeclaration18.errors.txt b/tests/baselines/reference/parserClassDeclaration18.errors.txt index 990b69a1013..ce4b01d5253 100644 --- a/tests/baselines/reference/parserClassDeclaration18.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration18.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration18.ts(4,25): error TS1111: A constructor implementation cannot be declared in an ambient context. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration18.ts(4,25): error TS1184: An implementation cannot be declared in ambient contexts. ==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration18.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclarat constructor(n: number); constructor(x: any) { ~ -!!! error TS1111: A constructor implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. } bar1():void; } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName11.errors.txt b/tests/baselines/reference/parserComputedPropertyName11.errors.txt index f47aa75031d..728d10e59d3 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1168: Computed property names are not allowed in method overloads. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts (2 errors) ==== class C { [e](); ~~~ !!! error TS1168: Computed property names are not allowed in method overloads. + ~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName14.errors.txt b/tests/baselines/reference/parserComputedPropertyName14.errors.txt index d2f7ad34ed9..e935314b4f1 100644 --- a/tests/baselines/reference/parserComputedPropertyName14.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName14.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1170: Computed property names are not allowed in type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts (2 errors) ==== var v: { [e](): number }; ~~~ -!!! error TS1170: Computed property names are not allowed in type literals. \ No newline at end of file +!!! error TS1170: Computed property names are not allowed in type literals. + ~~~ +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName18.errors.txt b/tests/baselines/reference/parserComputedPropertyName18.errors.txt index 72833dda837..8539a568389 100644 --- a/tests/baselines/reference/parserComputedPropertyName18.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName18.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1170: Computed property names are not allowed in type literals. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts (2 errors) ==== var v: { [e]?(): number }; ~~~ -!!! error TS1170: Computed property names are not allowed in type literals. \ No newline at end of file +!!! error TS1170: Computed property names are not allowed in type literals. + ~~~ +!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName20.errors.txt b/tests/baselines/reference/parserComputedPropertyName20.errors.txt index 36a7e2d4866..e743e7f94b5 100644 --- a/tests/baselines/reference/parserComputedPropertyName20.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName20.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: Computed property names are not allowed in interfaces. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts (2 errors) ==== interface I { [e](): number ~~~ !!! error TS1169: Computed property names are not allowed in interfaces. + ~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName23.errors.txt b/tests/baselines/reference/parserComputedPropertyName23.errors.txt index 2018032ef94..317f198e4d4 100644 --- a/tests/baselines/reference/parserComputedPropertyName23.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName23.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts(2,9): error TS1086: An accessor cannot be declared in an ambient context. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts(2,9): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts (2 errors) ==== declare class C { get [e](): number ~~~ !!! error TS1086: An accessor cannot be declared in an ambient context. + ~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName32.errors.txt b/tests/baselines/reference/parserComputedPropertyName32.errors.txt index 4407014cf99..7aba423d690 100644 --- a/tests/baselines/reference/parserComputedPropertyName32.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName32.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1165: Computed property names are not allowed in an ambient context. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts (2 errors) ==== declare class C { [e](): number ~~~ !!! error TS1165: Computed property names are not allowed in an ambient context. + ~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserConstructorDeclaration11.errors.txt b/tests/baselines/reference/parserConstructorDeclaration11.errors.txt index 7e5c305fb80..e8a799fc36a 100644 --- a/tests/baselines/reference/parserConstructorDeclaration11.errors.txt +++ b/tests/baselines/reference/parserConstructorDeclaration11.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts(2,14): error TS1098: Type parameter list cannot be empty. +tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts(2,15): error TS1092: Type parameters cannot appear on a constructor declaration. -==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts (2 errors) ==== class C { constructor<>() { } ~~ !!! error TS1098: Type parameter list cannot be empty. + +!!! error TS1092: Type parameters cannot appear on a constructor declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/parserConstructorDeclaration12.errors.txt b/tests/baselines/reference/parserConstructorDeclaration12.errors.txt index 181a3b2215f..8f0a872a0af 100644 --- a/tests/baselines/reference/parserConstructorDeclaration12.errors.txt +++ b/tests/baselines/reference/parserConstructorDeclaration12.errors.txt @@ -1,61 +1,85 @@ tests/cases/compiler/parserConstructorDeclaration12.ts(2,3): error TS2392: Multiple constructor implementations are not allowed. tests/cases/compiler/parserConstructorDeclaration12.ts(2,14): error TS1098: Type parameter list cannot be empty. +tests/cases/compiler/parserConstructorDeclaration12.ts(2,15): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(3,3): error TS2392: Multiple constructor implementations are not allowed. tests/cases/compiler/parserConstructorDeclaration12.ts(3,14): error TS1098: Type parameter list cannot be empty. +tests/cases/compiler/parserConstructorDeclaration12.ts(3,15): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(4,3): error TS2392: Multiple constructor implementations are not allowed. tests/cases/compiler/parserConstructorDeclaration12.ts(4,15): error TS1098: Type parameter list cannot be empty. +tests/cases/compiler/parserConstructorDeclaration12.ts(4,16): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(5,3): error TS2392: Multiple constructor implementations are not allowed. tests/cases/compiler/parserConstructorDeclaration12.ts(5,15): error TS1098: Type parameter list cannot be empty. +tests/cases/compiler/parserConstructorDeclaration12.ts(5,16): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(6,3): error TS2392: Multiple constructor implementations are not allowed. tests/cases/compiler/parserConstructorDeclaration12.ts(6,14): error TS1098: Type parameter list cannot be empty. +tests/cases/compiler/parserConstructorDeclaration12.ts(6,15): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(7,3): error TS2392: Multiple constructor implementations are not allowed. tests/cases/compiler/parserConstructorDeclaration12.ts(7,14): error TS1098: Type parameter list cannot be empty. +tests/cases/compiler/parserConstructorDeclaration12.ts(7,15): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(8,3): error TS2392: Multiple constructor implementations are not allowed. tests/cases/compiler/parserConstructorDeclaration12.ts(8,15): error TS1098: Type parameter list cannot be empty. +tests/cases/compiler/parserConstructorDeclaration12.ts(8,16): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(9,3): error TS2392: Multiple constructor implementations are not allowed. tests/cases/compiler/parserConstructorDeclaration12.ts(9,15): error TS1098: Type parameter list cannot be empty. +tests/cases/compiler/parserConstructorDeclaration12.ts(9,16): error TS1092: Type parameters cannot appear on a constructor declaration. -==== tests/cases/compiler/parserConstructorDeclaration12.ts (16 errors) ==== +==== tests/cases/compiler/parserConstructorDeclaration12.ts (24 errors) ==== class C { constructor<>() { } ~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. ~~ !!! error TS1098: Type parameter list cannot be empty. + +!!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor<> () { } ~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. ~~ !!! error TS1098: Type parameter list cannot be empty. + +!!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor <>() { } ~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. ~~ !!! error TS1098: Type parameter list cannot be empty. + +!!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor <> () { } ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. ~~ !!! error TS1098: Type parameter list cannot be empty. + +!!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor< >() { } ~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. ~~~ !!! error TS1098: Type parameter list cannot be empty. + +!!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor< > () { } ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. ~~~ !!! error TS1098: Type parameter list cannot be empty. + +!!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor < >() { } ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. ~~~ !!! error TS1098: Type parameter list cannot be empty. + +!!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor < > () { } ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. ~~~ !!! error TS1098: Type parameter list cannot be empty. + +!!! error TS1092: Type parameters cannot appear on a constructor declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/parserConstructorDeclaration4.errors.txt b/tests/baselines/reference/parserConstructorDeclaration4.errors.txt index bd27ccbb255..e851885f0ee 100644 --- a/tests/baselines/reference/parserConstructorDeclaration4.errors.txt +++ b/tests/baselines/reference/parserConstructorDeclaration4.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts(2,3): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts(2,25): error TS1184: An implementation cannot be declared in ambient contexts. -==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts (2 errors) ==== class C { declare constructor() { } ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. + ~ +!!! error TS1184: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserContinueStatement1.d.errors.txt b/tests/baselines/reference/parserContinueStatement1.d.errors.txt index a143922a761..f16e32987a2 100644 --- a/tests/baselines/reference/parserContinueStatement1.d.errors.txt +++ b/tests/baselines/reference/parserContinueStatement1.d.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserContinueStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/conformance/parser/ecmascript5/Statements/parserContinueStatement1.d.ts(1,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserContinueStatement1.d.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserContinueStatement1.d.ts (2 errors) ==== continue; ~~~~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. \ No newline at end of file +!!! error TS1036: Statements are not allowed in ambient contexts. + ~~~~~~~~~ +!!! error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt index 124db7da75a..1e4a532d132 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1168: Computed property names are not allowed in method overloads. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts (2 errors) ==== class C { [e](); ~~~ !!! error TS1168: Computed property names are not allowed in method overloads. + ~~~ +!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserFunctionDeclaration2.d.errors.txt b/tests/baselines/reference/parserFunctionDeclaration2.d.errors.txt index f623642e827..9aee5f2b0e7 100644 --- a/tests/baselines/reference/parserFunctionDeclaration2.d.errors.txt +++ b/tests/baselines/reference/parserFunctionDeclaration2.d.errors.txt @@ -1,8 +1,11 @@ tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. +tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts(1,14): error TS1184: An implementation cannot be declared in ambient contexts. -==== tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts (2 errors) ==== function F() { ~~~~~~~~ !!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. + ~ +!!! error TS1184: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserFunctionDeclaration2.errors.txt b/tests/baselines/reference/parserFunctionDeclaration2.errors.txt index 0b09c7c6956..deb96553220 100644 --- a/tests/baselines/reference/parserFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/parserFunctionDeclaration2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.ts(1,24): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.ts(1,24): error TS1184: An implementation cannot be declared in ambient contexts. ==== tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.ts (1 errors) ==== declare function Foo() { ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt index dc19cb0f855..12fb40ad232 100644 --- a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt +++ b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt @@ -1,9 +1,12 @@ tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. +tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,19): error TS1184: An implementation cannot be declared in ambient contexts. -==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (2 errors) ==== class C { declare Foo() { } ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. + ~ +!!! error TS1184: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserModuleDeclaration4.d.errors.txt b/tests/baselines/reference/parserModuleDeclaration4.d.errors.txt index 3f7cc9c53d3..2e75c6cbc50 100644 --- a/tests/baselines/reference/parserModuleDeclaration4.d.errors.txt +++ b/tests/baselines/reference/parserModuleDeclaration4.d.errors.txt @@ -1,10 +1,13 @@ tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModuleDeclaration4.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. +tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModuleDeclaration4.d.ts(2,3): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -==== tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModuleDeclaration4.d.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ModuleDeclarations/parserModuleDeclaration4.d.ts (2 errors) ==== module M { ~~~~~~ !!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. declare module M1 { + ~~~~~~~ +!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. } } \ No newline at end of file diff --git a/tests/baselines/reference/parserReturnStatement1.d.errors.txt b/tests/baselines/reference/parserReturnStatement1.d.errors.txt index 844be85439e..097a19a2bfe 100644 --- a/tests/baselines/reference/parserReturnStatement1.d.errors.txt +++ b/tests/baselines/reference/parserReturnStatement1.d.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserReturnStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/conformance/parser/ecmascript5/Statements/parserReturnStatement1.d.ts(1,1): error TS1108: A 'return' statement can only be used within a function body. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserReturnStatement1.d.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserReturnStatement1.d.ts (2 errors) ==== return; ~~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. \ No newline at end of file +!!! error TS1036: Statements are not allowed in ambient contexts. + ~~~~~~ +!!! error TS1108: A 'return' statement can only be used within a function body. \ No newline at end of file diff --git a/tests/baselines/reference/parserVariableStatement1.d.errors.txt b/tests/baselines/reference/parserVariableStatement1.d.errors.txt index 7176e5ed69f..de0bef5288c 100644 --- a/tests/baselines/reference/parserVariableStatement1.d.errors.txt +++ b/tests/baselines/reference/parserVariableStatement1.d.errors.txt @@ -1,7 +1,10 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserVariableStatement1.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. +tests/cases/conformance/parser/ecmascript5/Statements/parserVariableStatement1.d.ts(1,7): error TS1039: Initializers are not allowed in ambient contexts. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserVariableStatement1.d.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserVariableStatement1.d.ts (2 errors) ==== var v = 1; ~~~ -!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. \ No newline at end of file +!!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. + ~ +!!! error TS1039: Initializers are not allowed in ambient contexts. \ No newline at end of file diff --git a/tests/baselines/reference/parserWithStatement2.errors.txt b/tests/baselines/reference/parserWithStatement2.errors.txt index c2d4b2efa96..bab548de06e 100644 --- a/tests/baselines/reference/parserWithStatement2.errors.txt +++ b/tests/baselines/reference/parserWithStatement2.errors.txt @@ -1,11 +1,8 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts(1,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts(2,3): error TS1108: A 'return' statement can only be used within a function body. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts (1 errors) ==== with (1) ~ !!! error TS2410: All symbols within a 'with' block will be resolved to 'any'. - return; - ~~~~~~ -!!! error TS1108: A 'return' statement can only be used within a function body. \ No newline at end of file + return; \ No newline at end of file diff --git a/tests/baselines/reference/parserWithStatement2.js b/tests/baselines/reference/parserWithStatement2.js new file mode 100644 index 00000000000..be3ed9c6c24 --- /dev/null +++ b/tests/baselines/reference/parserWithStatement2.js @@ -0,0 +1,7 @@ +//// [parserWithStatement2.ts] +with (1) + return; + +//// [parserWithStatement2.js] +with (1) + return; diff --git a/tests/baselines/reference/semicolonsInModuleDeclarations.errors.txt b/tests/baselines/reference/semicolonsInModuleDeclarations.errors.txt index 920d5007509..64b95f124a6 100644 --- a/tests/baselines/reference/semicolonsInModuleDeclarations.errors.txt +++ b/tests/baselines/reference/semicolonsInModuleDeclarations.errors.txt @@ -1,10 +1,13 @@ tests/cases/compiler/semicolonsInModuleDeclarations.ts(2,27): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/compiler/semicolonsInModuleDeclarations.ts(2,27): error TS1036: Statements are not allowed in ambient contexts. -==== tests/cases/compiler/semicolonsInModuleDeclarations.ts (1 errors) ==== +==== tests/cases/compiler/semicolonsInModuleDeclarations.ts (2 errors) ==== declare module ambiModule { export interface i1 { }; ~ +!!! error TS1036: Statements are not allowed in ambient contexts. + ~ !!! error TS1036: Statements are not allowed in ambient contexts. export interface i2 { } } diff --git a/tests/baselines/reference/switchStatementsWithMultipleDefaults.errors.txt b/tests/baselines/reference/switchStatementsWithMultipleDefaults.errors.txt index 10568608a79..c911886c670 100644 --- a/tests/baselines/reference/switchStatementsWithMultipleDefaults.errors.txt +++ b/tests/baselines/reference/switchStatementsWithMultipleDefaults.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(9,5): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement. tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(21,13): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement. +tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(28,22): error TS1108: A 'return' statement can only be used within a function body. -==== tests/cases/compiler/switchStatementsWithMultipleDefaults.ts (2 errors) ==== +==== tests/cases/compiler/switchStatementsWithMultipleDefaults.ts (3 errors) ==== var x = 10; @@ -35,6 +36,8 @@ tests/cases/compiler/switchStatementsWithMultipleDefaults.ts(21,13): error TS111 def\u0061ult: // Error, fourth 'default' clause. // Errors on fifth-seventh default: return; + ~~~~~~ +!!! error TS1108: A 'return' statement can only be used within a function body. default: default: } } \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt index a9b9e45a33c..6b389218f65 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt @@ -7,15 +7,18 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,19): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,40): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,50): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (15 errors) ==== +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (18 errors) ==== interface I { (stringParts: string[], ...rest: boolean[]): I; g: I; @@ -58,18 +61,24 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`[0].member `abc${1}def${2}ghi`; + ~~~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~ !!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + ~~~~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. ~~~~~~ !!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`; + ~~~~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~ !!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt index 4ea0304f421..2557d6cc94a 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt @@ -6,11 +6,13 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,32): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,46): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts (10 errors) ==== +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts (12 errors) ==== var f: any; f `abc` @@ -46,10 +48,14 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts !!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; + ~~~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~ !!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; + ~~~~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~ !!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt index 173d3a6b741..28050ec96c1 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt @@ -4,11 +4,13 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(16,3 tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(18,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(20,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(22,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,19): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,40): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts (8 errors) ==== +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts (10 errors) ==== interface I { (stringParts: string[], ...rest: number[]): I; g: I; @@ -45,10 +47,14 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,4 !!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc`[0].member `abc${1}def${2}ghi`; + ~~~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~ !!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + ~~~~~~ +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~ !!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. diff --git a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt index 24d64d8f29e..7b28cf64ae9 100644 --- a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt +++ b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt @@ -1,11 +1,14 @@ tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(3,13): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts (1 errors) ==== +==== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts (2 errors) ==== function* gen() { ~ !!! error TS9001: Generators are not currently supported. // Once this is supported, the inner expression does not need to be parenthesized. var x = yield `abc${ x }def`; + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt index 20542cb12b7..46ca3c74b95 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt @@ -1,11 +1,14 @@ tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,20): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts (1 errors) ==== +==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts (2 errors) ==== function* gen() { ~ !!! error TS9001: Generators are not currently supported. // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/yieldExpression1.errors.txt b/tests/baselines/reference/yieldExpression1.errors.txt index 33d9c1bf62e..91a379e6172 100644 --- a/tests/baselines/reference/yieldExpression1.errors.txt +++ b/tests/baselines/reference/yieldExpression1.errors.txt @@ -1,9 +1,12 @@ tests/cases/compiler/yieldExpression1.ts(1,9): error TS9001: Generators are not currently supported. +tests/cases/compiler/yieldExpression1.ts(2,5): error TS9000: 'yield' expressions are not currently supported. -==== tests/cases/compiler/yieldExpression1.ts (1 errors) ==== +==== tests/cases/compiler/yieldExpression1.ts (2 errors) ==== function* foo() { ~ !!! error TS9001: Generators are not currently supported. yield + ~~~~~ +!!! error TS9000: 'yield' expressions are not currently supported. } \ No newline at end of file From d7f607234ace2d53ae332e13b046be45321caac1 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 16 Dec 2014 19:30:08 -0800 Subject: [PATCH 71/74] COMPLETE migrating grammar checking; No more errors --- src/compiler/checker.ts | 35 ++--- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 3 +- .../reference/ambientErrors.errors.txt | 8 +- .../reference/externSyntax.errors.txt | 4 +- tests/baselines/reference/giant.errors.txt | 124 +++++++++--------- .../initializersInDeclarations.errors.txt | 4 +- .../methodInAmbientClass1.errors.txt | 4 +- .../privacyGloImportParseErrors.errors.txt | 17 ++- .../privacyImportParseErrors.errors.txt | 35 ++++- .../amd/intReferencingExtAndInt.errors.txt | 5 +- .../node/intReferencingExtAndInt.errors.txt | 5 +- ...calModuleWithRecursiveTypecheck.errors.txt | 5 +- ...calModuleWithRecursiveTypecheck.errors.txt | 5 +- ...dModuleDeclarationsInsideModule.errors.txt | 11 +- ...dModuleDeclarationsInsideModule.errors.txt | 11 +- ...arationsInsideNonExportedModule.errors.txt | 11 +- ...arationsInsideNonExportedModule.errors.txt | 11 +- ...leImportStatementInParentModule.errors.txt | 11 +- ...leImportStatementInParentModule.errors.txt | 11 +- .../semicolonsInModuleDeclarations.errors.txt | 5 +- 21 files changed, 216 insertions(+), 111 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 633d1a8299d..2f45f5bdfbf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7021,14 +7021,7 @@ module ts { function checkNumericLiteral(node: LiteralExpression): Type { // Grammar checking - if (node.flags & NodeFlags.OctalLiteral) { - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (compilerOptions.target >= ScriptTarget.ES5) { - grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } - } + checkGrammarNumbericLiteral(node); return numberType; } @@ -10362,8 +10355,7 @@ module ts { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop,(prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === SyntaxKind.NumericLiteral) { - } - else if (name.kind === SyntaxKind.StringLiteral) { + checkGrammarNumbericLiteral(name); } currentKind = Property; } @@ -10455,7 +10447,6 @@ module ts { function checkGrammarMethod(node: MethodDeclaration) { if (checkGrammarFunctionLikeDeclaration(node) || - checkGrammarForBodyInAmbientContext(node.body, /*isConstructor:*/ false) || checkGrammarForGenerator(node)) { return true; } @@ -10734,16 +10725,6 @@ module ts { } } - function checkGrammarForBodyInAmbientContext(body: Block | Expression, isConstructor: boolean): boolean { - if (isInAmbientContext(body) && body && body.kind === SyntaxKind.Block) { - - var diagnostic = isConstructor - ? Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context - : Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; - return getNodeLinks(body).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(body, diagnostic); - } - } - function checkGrammarProperty(node: PropertyDeclaration) { if (node.parent.kind === SyntaxKind.ClassDeclaration) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, Diagnostics.A_class_member_cannot_be_declared_optional) || @@ -10839,6 +10820,18 @@ module ts { } } + function checkGrammarNumbericLiteral(node: Identifier): boolean { + // Grammar checking + if (node.flags & NodeFlags.OctalLiteral) { + if (node.parserContextFlags & ParserContextFlags.StrictMode) { + return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); + } + else if (compilerOptions.target >= ScriptTarget.ES5) { + return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); + } + } + } + function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { var sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index a0952cb9f8e..55399deaabe 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -50,7 +50,7 @@ module ts { An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module.", isEarly: true }, Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers.", isEarly: true }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration.", isEarly: true }, Invalid_reference_directive_syntax: { code: 1084, category: DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher.", isEarly: true }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context.", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6e724839803..fb3e50e3065 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -228,7 +228,8 @@ }, "A 'declare' modifier cannot be used with an import declaration.": { "category": "Error", - "code": 1079 + "code": 1079, + "isEarly": true }, "Invalid 'reference' directive syntax.": { "category": "Error", diff --git a/tests/baselines/reference/ambientErrors.errors.txt b/tests/baselines/reference/ambientErrors.errors.txt index eb06b785914..c8159708dd8 100644 --- a/tests/baselines/reference/ambientErrors.errors.txt +++ b/tests/baselines/reference/ambientErrors.errors.txt @@ -9,8 +9,8 @@ tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1184: An implem tests/cases/conformance/ambient/ambientErrors.ts(37,20): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(38,13): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(39,23): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(47,20): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/conformance/ambient/ambientErrors.ts(51,16): error TS2436: Ambient external module declaration cannot specify relative module name. tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -80,10 +80,10 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export !!! error TS1184: An implementation cannot be declared in ambient contexts. fn() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static sfn() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. } } diff --git a/tests/baselines/reference/externSyntax.errors.txt b/tests/baselines/reference/externSyntax.errors.txt index 099c9fa3a99..1d3380b99d5 100644 --- a/tests/baselines/reference/externSyntax.errors.txt +++ b/tests/baselines/reference/externSyntax.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/externSyntax.ts(8,20): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/externSyntax.ts(8,20): error TS1184: An implementation cannot be declared in ambient contexts. ==== tests/cases/compiler/externSyntax.ts (1 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/externSyntax.ts(8,20): error TS1037: A function implementat public f(); public g() { } // error body ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. } } diff --git a/tests/baselines/reference/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index 5a356ab6f2a..fbe05bbfc79 100644 --- a/tests/baselines/reference/giant.errors.txt +++ b/tests/baselines/reference/giant.errors.txt @@ -68,31 +68,31 @@ tests/cases/compiler/giant.ts(219,9): error TS2386: Overload signatures must all tests/cases/compiler/giant.ts(233,39): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(238,35): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(240,24): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(243,21): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(244,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(243,21): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(244,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(245,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(245,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(245,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(246,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(246,20): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(247,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(247,31): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(247,31): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(248,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(248,20): error TS2300: Duplicate identifier 'psF'. tests/cases/compiler/giant.ts(249,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(249,23): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(249,23): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(250,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(250,21): error TS2300: Duplicate identifier 'rgF'. tests/cases/compiler/giant.ts(251,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(251,32): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(251,32): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(252,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(252,21): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(254,21): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(254,21): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(255,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(255,31): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(255,31): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(256,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(256,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(257,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(257,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(257,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(258,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(258,20): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(262,22): error TS1184: An implementation cannot be declared in ambient contexts. @@ -168,31 +168,31 @@ tests/cases/compiler/giant.ts(477,9): error TS2386: Overload signatures must all tests/cases/compiler/giant.ts(491,39): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(496,35): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(498,24): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(501,21): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(502,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(501,21): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(502,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(503,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(503,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(503,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(504,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(504,20): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(505,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(505,31): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(505,31): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(506,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(506,20): error TS2300: Duplicate identifier 'psF'. tests/cases/compiler/giant.ts(507,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(507,23): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(507,23): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(508,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(508,21): error TS2300: Duplicate identifier 'rgF'. tests/cases/compiler/giant.ts(509,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(509,32): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(509,32): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(510,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(510,21): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(512,21): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(512,21): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(513,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(513,31): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(513,31): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(514,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(514,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(515,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(515,22): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(515,22): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(516,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(516,20): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(520,22): error TS1184: An implementation cannot be declared in ambient contexts. @@ -200,38 +200,38 @@ tests/cases/compiler/giant.ts(520,25): error TS1036: Statements are not allowed tests/cases/compiler/giant.ts(525,30): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(532,31): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(534,20): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(537,17): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(538,18): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(537,17): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(538,18): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(539,12): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(539,18): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(539,18): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(540,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(540,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(541,12): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(541,27): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(541,27): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(542,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(542,16): error TS2300: Duplicate identifier 'psF'. tests/cases/compiler/giant.ts(543,13): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(543,19): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(543,19): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(544,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(544,17): error TS2300: Duplicate identifier 'rgF'. tests/cases/compiler/giant.ts(545,13): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(545,28): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(545,28): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(546,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(546,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(548,17): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(548,17): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(549,12): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(549,27): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(549,27): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(550,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(550,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(551,12): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(551,18): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(551,18): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(552,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(552,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(556,18): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(556,21): error TS1036: Statements are not allowed in ambient contexts. tests/cases/compiler/giant.ts(558,24): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(561,21): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(563,21): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(561,21): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(563,21): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(587,9): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter. @@ -246,8 +246,8 @@ tests/cases/compiler/giant.ts(617,16): error TS1038: A 'declare' modifier cannot tests/cases/compiler/giant.ts(618,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/giant.ts(621,26): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(623,24): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(626,21): error TS1037: A function implementation cannot be declared in an ambient context. -tests/cases/compiler/giant.ts(628,21): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/giant.ts(626,21): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(628,21): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(653,9): error TS1169: Computed property names are not allowed in interfaces. tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter. @@ -642,15 +642,15 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be private rV; public pF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. private rF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public pgF() { } ~~~ !!! error TS2300: Duplicate identifier 'pgF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public get pgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -660,7 +660,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'psF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public set psF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -670,7 +670,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rgF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. private get rgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -680,7 +680,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rsF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. private set rsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -689,12 +689,12 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be static tV; static tF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static tsF(param:any) { } ~~~ !!! error TS2300: Duplicate identifier 'tsF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static set tsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -704,7 +704,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'tgF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static get tgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1100,15 +1100,15 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be private rV; public pF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. private rF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public pgF() { } ~~~ !!! error TS2300: Duplicate identifier 'pgF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public get pgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1118,7 +1118,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'psF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public set psF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1128,7 +1128,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rgF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. private get rgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1138,7 +1138,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rsF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. private set rsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1147,12 +1147,12 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be static tV; static tF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static tsF(param:any) { } ~~~ !!! error TS2300: Duplicate identifier 'tsF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static set tsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1162,7 +1162,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'tgF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static get tgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1200,15 +1200,15 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be private rV; public pF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. private rF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public pgF() { } ~~~ !!! error TS2300: Duplicate identifier 'pgF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public get pgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1218,7 +1218,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'psF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. public set psF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1228,7 +1228,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rgF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. private get rgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1238,7 +1238,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rsF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. private set rsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1247,12 +1247,12 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be static tV; static tF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static tsF(param:any) { } ~~~ !!! error TS2300: Duplicate identifier 'tsF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static set tsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1262,7 +1262,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'tgF'. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static get tgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1284,11 +1284,11 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be private rV; public pF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static tV; static tF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. } interface I { //Call Signature @@ -1381,11 +1381,11 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be private rV; public pF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. static tV static tF() { } ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. } export interface eI { //Call Signature diff --git a/tests/baselines/reference/initializersInDeclarations.errors.txt b/tests/baselines/reference/initializersInDeclarations.errors.txt index 5ab9ae5d2bc..9840181e092 100644 --- a/tests/baselines/reference/initializersInDeclarations.errors.txt +++ b/tests/baselines/reference/initializersInDeclarations.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/externalModules/initializersInDeclarations.ts(5,9): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(6,16): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/conformance/externalModules/initializersInDeclarations.ts(7,16): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/conformance/externalModules/initializersInDeclarations.ts(7,16): error TS1184: An implementation cannot be declared in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(12,15): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(13,15): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(16,2): error TS1036: Statements are not allowed in ambient contexts. @@ -20,7 +20,7 @@ tests/cases/conformance/externalModules/initializersInDeclarations.ts(18,16): er !!! error TS1039: Initializers are not allowed in ambient contexts. fn(): boolean { ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. return false; } } diff --git a/tests/baselines/reference/methodInAmbientClass1.errors.txt b/tests/baselines/reference/methodInAmbientClass1.errors.txt index 2c99dfdde0a..05183378a85 100644 --- a/tests/baselines/reference/methodInAmbientClass1.errors.txt +++ b/tests/baselines/reference/methodInAmbientClass1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/methodInAmbientClass1.ts(2,12): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. -tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1037: A function implementation cannot be declared in an ambient context. +tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1184: An implementation cannot be declared in ambient contexts. ==== tests/cases/compiler/methodInAmbientClass1.ts (2 errors) ==== @@ -8,6 +8,6 @@ tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1037: A function im ~~~~~~~ !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~ -!!! error TS1037: A function implementation cannot be declared in an ambient context. +!!! error TS1184: An implementation cannot be declared in ambient contexts. } } \ No newline at end of file diff --git a/tests/baselines/reference/privacyGloImportParseErrors.errors.txt b/tests/baselines/reference/privacyGloImportParseErrors.errors.txt index 5c632c09cd4..fa3b1bb522d 100644 --- a/tests/baselines/reference/privacyGloImportParseErrors.errors.txt +++ b/tests/baselines/reference/privacyGloImportParseErrors.errors.txt @@ -2,16 +2,21 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(22,27): error TS2435: Ambien tests/cases/compiler/privacyGloImportParseErrors.ts(30,20): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyGloImportParseErrors.ts(59,37): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyGloImportParseErrors.ts(59,37): error TS2307: Cannot find external module 'm1_M3_public'. +tests/cases/compiler/privacyGloImportParseErrors.ts(69,37): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyGloImportParseErrors.ts(69,37): error TS2307: Cannot find external module 'm1_M4_private'. +tests/cases/compiler/privacyGloImportParseErrors.ts(81,43): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyGloImportParseErrors.ts(82,43): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyGloImportParseErrors.ts(121,38): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyGloImportParseErrors.ts(125,45): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyGloImportParseErrors.ts(133,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/privacyGloImportParseErrors.ts(133,24): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyGloImportParseErrors.ts(138,16): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyGloImportParseErrors.ts(141,12): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyGloImportParseErrors.ts(146,25): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyGloImportParseErrors.ts(149,29): error TS1147: Import declarations in an internal module cannot reference an external module. -==== tests/cases/compiler/privacyGloImportParseErrors.ts (11 errors) ==== +==== tests/cases/compiler/privacyGloImportParseErrors.ts (16 errors) ==== module m1 { export module m1_M1_public { export class c1 { @@ -90,6 +95,8 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(146,25): error TS1147: Impor import m1_im4_private = require("m1_M4_private"); ~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~~ !!! error TS2307: Cannot find external module 'm1_M4_private'. export var m1_im4_private_v1_public = m1_im4_private.c1; export var m1_im4_private_v2_public = new m1_im4_private.c1(); @@ -103,7 +110,11 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(146,25): error TS1147: Impor export import m1_im1_public = m1_M1_public; export import m1_im2_public = m1_M2_private; export import m1_im3_public = require("m1_M3_public"); + ~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. export import m1_im4_public = require("m1_M4_private"); + ~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. } module glo_M1_public { @@ -149,6 +160,8 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(146,25): error TS1147: Impor module m5 { import m5_errorImport = require("glo_M2_public"); + ~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. import m5_nonerrorImport = glo_M1_public; } } @@ -183,6 +196,8 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(146,25): error TS1147: Impor module m4 { var a = 10; import m2 = require("use_glo_M1_public"); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. } } \ No newline at end of file diff --git a/tests/baselines/reference/privacyImportParseErrors.errors.txt b/tests/baselines/reference/privacyImportParseErrors.errors.txt index 51199196ad7..a81bfbe738b 100644 --- a/tests/baselines/reference/privacyImportParseErrors.errors.txt +++ b/tests/baselines/reference/privacyImportParseErrors.errors.txt @@ -2,12 +2,18 @@ tests/cases/compiler/privacyImportParseErrors.ts(22,27): error TS2435: Ambient e tests/cases/compiler/privacyImportParseErrors.ts(30,20): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(59,37): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(59,37): error TS2307: Cannot find external module 'm1_M3_public'. +tests/cases/compiler/privacyImportParseErrors.ts(69,37): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(69,37): error TS2307: Cannot find external module 'm1_M4_private'. +tests/cases/compiler/privacyImportParseErrors.ts(81,43): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyImportParseErrors.ts(82,43): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(106,27): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(114,20): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(143,37): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(143,37): error TS2307: Cannot find external module 'm2_M3_public'. +tests/cases/compiler/privacyImportParseErrors.ts(153,37): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(153,37): error TS2307: Cannot find external module 'm2_M4_private'. +tests/cases/compiler/privacyImportParseErrors.ts(166,43): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyImportParseErrors.ts(167,43): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(180,23): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(198,23): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(218,34): error TS2307: Cannot find external module 'glo_M2_public'. @@ -19,11 +25,13 @@ tests/cases/compiler/privacyImportParseErrors.ts(258,45): error TS2304: Cannot f tests/cases/compiler/privacyImportParseErrors.ts(261,39): error TS2304: Cannot find name 'use_glo_M1_public'. tests/cases/compiler/privacyImportParseErrors.ts(264,40): error TS2307: Cannot find external module 'glo_M2_public'. tests/cases/compiler/privacyImportParseErrors.ts(273,38): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyImportParseErrors.ts(277,45): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(284,16): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(287,46): error TS2304: Cannot find name 'use_glo_M3_private'. tests/cases/compiler/privacyImportParseErrors.ts(290,40): error TS2304: Cannot find name 'use_glo_M3_private'. tests/cases/compiler/privacyImportParseErrors.ts(293,41): error TS2307: Cannot find external module 'glo_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(302,38): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyImportParseErrors.ts(306,45): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(312,16): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(314,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/privacyImportParseErrors.ts(314,24): error TS2435: Ambient external modules cannot be nested in other modules. @@ -31,14 +39,17 @@ tests/cases/compiler/privacyImportParseErrors.ts(319,16): error TS2435: Ambient tests/cases/compiler/privacyImportParseErrors.ts(322,12): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(326,9): error TS1029: 'export' modifier must precede 'declare' modifier. tests/cases/compiler/privacyImportParseErrors.ts(326,23): error TS2435: Ambient external modules cannot be nested in other modules. +tests/cases/compiler/privacyImportParseErrors.ts(328,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/privacyImportParseErrors.ts(328,24): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(333,16): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(336,12): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(341,25): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyImportParseErrors.ts(344,29): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import declarations in an internal module cannot reference an external module. -==== tests/cases/compiler/privacyImportParseErrors.ts (38 errors) ==== +==== tests/cases/compiler/privacyImportParseErrors.ts (49 errors) ==== export module m1 { export module m1_M1_public { export class c1 { @@ -117,6 +128,8 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d import m1_im4_private = require("m1_M4_private"); ~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~~ !!! error TS2307: Cannot find external module 'm1_M4_private'. export var m1_im4_private_v1_public = m1_im4_private.c1; export var m1_im4_private_v2_public = new m1_im4_private.c1(); @@ -130,7 +143,11 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d export import m1_im1_public = m1_M1_public; export import m1_im2_public = m1_M2_private; export import m1_im3_public = require("m1_M3_public"); + ~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. export import m1_im4_public = require("m1_M4_private"); + ~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. } module m2 { @@ -211,6 +228,8 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d import m1_im4_private = require("m2_M4_private"); ~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~~ !!! error TS2307: Cannot find external module 'm2_M4_private'. export var m1_im4_private_v1_public = m1_im4_private.c1; export var m1_im4_private_v2_public = new m1_im4_private.c1(); @@ -225,7 +244,11 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d export import m1_im1_public = m2_M1_public; export import m1_im2_public = m2_M2_private; export import m1_im3_public = require("m2_M3_public"); + ~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. export import m1_im4_public = require("m2_M4_private"); + ~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. } export module glo_M1_public { @@ -358,6 +381,8 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d module m5 { import m5_errorImport = require("glo_M2_public"); + ~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. import m5_nonerrorImport = glo_M1_public; } } @@ -397,6 +422,8 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d module m5 { import m5_errorImport = require("glo_M4_private"); + ~~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. import m5_nonerrorImport = glo_M3_private; } } @@ -433,6 +460,8 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d !!! error TS2435: Ambient external modules cannot be nested in other modules. module m2 { declare module "abc" { + ~~~~~~~ +!!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. ~~~~~ !!! error TS2435: Ambient external modules cannot be nested in other modules. } @@ -457,6 +486,8 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d module m4 { var a = 10; import m2 = require("use_glo_M1_public"); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. } } @@ -468,6 +499,8 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d module m4 { var a = 10; import m2 = require("use_glo_M1_public"); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. } } \ No newline at end of file diff --git a/tests/baselines/reference/project/intReferencingExtAndInt/amd/intReferencingExtAndInt.errors.txt b/tests/baselines/reference/project/intReferencingExtAndInt/amd/intReferencingExtAndInt.errors.txt index fd808bc1443..bfc09e40188 100644 --- a/tests/baselines/reference/project/intReferencingExtAndInt/amd/intReferencingExtAndInt.errors.txt +++ b/tests/baselines/reference/project/intReferencingExtAndInt/amd/intReferencingExtAndInt.errors.txt @@ -1,11 +1,14 @@ internal2.ts(2,21): error TS1147: Import declarations in an internal module cannot reference an external module. +internal2.ts(2,21): error TS2307: Cannot find external module 'external2'. -==== internal2.ts (1 errors) ==== +==== internal2.ts (2 errors) ==== module outer { import g = require("external2") ~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'external2'. export var a = g.square(5); export var b = "foo"; } \ No newline at end of file diff --git a/tests/baselines/reference/project/intReferencingExtAndInt/node/intReferencingExtAndInt.errors.txt b/tests/baselines/reference/project/intReferencingExtAndInt/node/intReferencingExtAndInt.errors.txt index fd808bc1443..bfc09e40188 100644 --- a/tests/baselines/reference/project/intReferencingExtAndInt/node/intReferencingExtAndInt.errors.txt +++ b/tests/baselines/reference/project/intReferencingExtAndInt/node/intReferencingExtAndInt.errors.txt @@ -1,11 +1,14 @@ internal2.ts(2,21): error TS1147: Import declarations in an internal module cannot reference an external module. +internal2.ts(2,21): error TS2307: Cannot find external module 'external2'. -==== internal2.ts (1 errors) ==== +==== internal2.ts (2 errors) ==== module outer { import g = require("external2") ~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'external2'. export var a = g.square(5); export var b = "foo"; } \ No newline at end of file diff --git a/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/amd/nestedLocalModuleWithRecursiveTypecheck.errors.txt b/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/amd/nestedLocalModuleWithRecursiveTypecheck.errors.txt index 9d1540829fc..e205f308c0a 100644 --- a/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/amd/nestedLocalModuleWithRecursiveTypecheck.errors.txt +++ b/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/amd/nestedLocalModuleWithRecursiveTypecheck.errors.txt @@ -1,12 +1,15 @@ test1.ts(3,23): error TS1147: Import declarations in an internal module cannot reference an external module. +test1.ts(3,23): error TS2307: Cannot find external module 'test2'. -==== test1.ts (1 errors) ==== +==== test1.ts (2 errors) ==== module myModule { import foo = require("test2"); ~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~ +!!! error TS2307: Cannot find external module 'test2'. //console.log(foo.$); diff --git a/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/node/nestedLocalModuleWithRecursiveTypecheck.errors.txt b/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/node/nestedLocalModuleWithRecursiveTypecheck.errors.txt index 9d1540829fc..e205f308c0a 100644 --- a/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/node/nestedLocalModuleWithRecursiveTypecheck.errors.txt +++ b/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/node/nestedLocalModuleWithRecursiveTypecheck.errors.txt @@ -1,12 +1,15 @@ test1.ts(3,23): error TS1147: Import declarations in an internal module cannot reference an external module. +test1.ts(3,23): error TS2307: Cannot find external module 'test2'. -==== test1.ts (1 errors) ==== +==== test1.ts (2 errors) ==== module myModule { import foo = require("test2"); ~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~ +!!! error TS2307: Cannot find external module 'test2'. //console.log(foo.$); diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/privacyCheckOnImportedModuleDeclarationsInsideModule.errors.txt b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/privacyCheckOnImportedModuleDeclarationsInsideModule.errors.txt index f15b4d3379b..eabc4e5656a 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/privacyCheckOnImportedModuleDeclarationsInsideModule.errors.txt +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/privacyCheckOnImportedModuleDeclarationsInsideModule.errors.txt @@ -1,11 +1,16 @@ testGlo.ts(2,39): error TS1147: Import declarations in an internal module cannot reference an external module. +testGlo.ts(2,39): error TS2307: Cannot find external module 'mExported'. +testGlo.ts(21,35): error TS1147: Import declarations in an internal module cannot reference an external module. +testGlo.ts(21,35): error TS2307: Cannot find external module 'mNonExported'. -==== testGlo.ts (1 errors) ==== +==== testGlo.ts (4 errors) ==== module m2 { export import mExported = require("mExported"); ~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mExported'. export var c1 = new mExported.me.class1; export function f1() { return new mExported.me.class1(); @@ -25,6 +30,10 @@ testGlo.ts(2,39): error TS1147: Import declarations in an internal module cannot } import mNonExported = require("mNonExported"); + ~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mNonExported'. export var c3 = new mNonExported.mne.class1; export function f3() { return new mNonExported.mne.class1(); diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/privacyCheckOnImportedModuleDeclarationsInsideModule.errors.txt b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/privacyCheckOnImportedModuleDeclarationsInsideModule.errors.txt index f15b4d3379b..eabc4e5656a 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/privacyCheckOnImportedModuleDeclarationsInsideModule.errors.txt +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/privacyCheckOnImportedModuleDeclarationsInsideModule.errors.txt @@ -1,11 +1,16 @@ testGlo.ts(2,39): error TS1147: Import declarations in an internal module cannot reference an external module. +testGlo.ts(2,39): error TS2307: Cannot find external module 'mExported'. +testGlo.ts(21,35): error TS1147: Import declarations in an internal module cannot reference an external module. +testGlo.ts(21,35): error TS2307: Cannot find external module 'mNonExported'. -==== testGlo.ts (1 errors) ==== +==== testGlo.ts (4 errors) ==== module m2 { export import mExported = require("mExported"); ~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mExported'. export var c1 = new mExported.me.class1; export function f1() { return new mExported.me.class1(); @@ -25,6 +30,10 @@ testGlo.ts(2,39): error TS1147: Import declarations in an internal module cannot } import mNonExported = require("mNonExported"); + ~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mNonExported'. export var c3 = new mNonExported.mne.class1; export function f3() { return new mNonExported.mne.class1(); diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/amd/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.errors.txt b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/amd/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.errors.txt index 8589da5c54d..820d18ffb98 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/amd/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.errors.txt +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/amd/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.errors.txt @@ -1,7 +1,10 @@ test.ts(5,39): error TS1147: Import declarations in an internal module cannot reference an external module. +test.ts(5,39): error TS2307: Cannot find external module 'mExported'. +test.ts(24,35): error TS1147: Import declarations in an internal module cannot reference an external module. +test.ts(24,35): error TS2307: Cannot find external module 'mNonExported'. -==== test.ts (1 errors) ==== +==== test.ts (4 errors) ==== export module m1 { } @@ -9,6 +12,8 @@ test.ts(5,39): error TS1147: Import declarations in an internal module cannot re export import mExported = require("mExported"); ~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mExported'. export var c1 = new mExported.me.class1; export function f1() { return new mExported.me.class1(); @@ -28,6 +33,10 @@ test.ts(5,39): error TS1147: Import declarations in an internal module cannot re } import mNonExported = require("mNonExported"); + ~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mNonExported'. export var c3 = new mNonExported.mne.class1; export function f3() { return new mNonExported.mne.class1(); diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/node/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.errors.txt b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/node/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.errors.txt index 8589da5c54d..820d18ffb98 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/node/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.errors.txt +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/node/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.errors.txt @@ -1,7 +1,10 @@ test.ts(5,39): error TS1147: Import declarations in an internal module cannot reference an external module. +test.ts(5,39): error TS2307: Cannot find external module 'mExported'. +test.ts(24,35): error TS1147: Import declarations in an internal module cannot reference an external module. +test.ts(24,35): error TS2307: Cannot find external module 'mNonExported'. -==== test.ts (1 errors) ==== +==== test.ts (4 errors) ==== export module m1 { } @@ -9,6 +12,8 @@ test.ts(5,39): error TS1147: Import declarations in an internal module cannot re export import mExported = require("mExported"); ~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mExported'. export var c1 = new mExported.me.class1; export function f1() { return new mExported.me.class1(); @@ -28,6 +33,10 @@ test.ts(5,39): error TS1147: Import declarations in an internal module cannot re } import mNonExported = require("mNonExported"); + ~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mNonExported'. export var c3 = new mNonExported.mne.class1; export function f3() { return new mNonExported.mne.class1(); diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/amd/privacyCheckOnImportedModuleImportStatementInParentModule.errors.txt b/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/amd/privacyCheckOnImportedModuleImportStatementInParentModule.errors.txt index c3c3a11c8b2..ed865949b87 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/amd/privacyCheckOnImportedModuleImportStatementInParentModule.errors.txt +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/amd/privacyCheckOnImportedModuleImportStatementInParentModule.errors.txt @@ -1,11 +1,16 @@ test.ts(2,39): error TS1147: Import declarations in an internal module cannot reference an external module. +test.ts(2,39): error TS2307: Cannot find external module 'mExported'. +test.ts(42,35): error TS1147: Import declarations in an internal module cannot reference an external module. +test.ts(42,35): error TS2307: Cannot find external module 'mNonExported'. -==== test.ts (1 errors) ==== +==== test.ts (4 errors) ==== export module m2 { export import mExported = require("mExported"); ~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mExported'. module Internal_M1 { export var c1 = new mExported.me.class1; @@ -46,6 +51,10 @@ test.ts(2,39): error TS1147: Import declarations in an internal module cannot re } import mNonExported = require("mNonExported"); + ~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mNonExported'. module Internal_M3 { export var c3 = new mNonExported.mne.class1; export function f3() { diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/node/privacyCheckOnImportedModuleImportStatementInParentModule.errors.txt b/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/node/privacyCheckOnImportedModuleImportStatementInParentModule.errors.txt index c3c3a11c8b2..ed865949b87 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/node/privacyCheckOnImportedModuleImportStatementInParentModule.errors.txt +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/node/privacyCheckOnImportedModuleImportStatementInParentModule.errors.txt @@ -1,11 +1,16 @@ test.ts(2,39): error TS1147: Import declarations in an internal module cannot reference an external module. +test.ts(2,39): error TS2307: Cannot find external module 'mExported'. +test.ts(42,35): error TS1147: Import declarations in an internal module cannot reference an external module. +test.ts(42,35): error TS2307: Cannot find external module 'mNonExported'. -==== test.ts (1 errors) ==== +==== test.ts (4 errors) ==== export module m2 { export import mExported = require("mExported"); ~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mExported'. module Internal_M1 { export var c1 = new mExported.me.class1; @@ -46,6 +51,10 @@ test.ts(2,39): error TS1147: Import declarations in an internal module cannot re } import mNonExported = require("mNonExported"); + ~~~~~~~~~~~~~~ +!!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'mNonExported'. module Internal_M3 { export var c3 = new mNonExported.mne.class1; export function f3() { diff --git a/tests/baselines/reference/semicolonsInModuleDeclarations.errors.txt b/tests/baselines/reference/semicolonsInModuleDeclarations.errors.txt index 64b95f124a6..920d5007509 100644 --- a/tests/baselines/reference/semicolonsInModuleDeclarations.errors.txt +++ b/tests/baselines/reference/semicolonsInModuleDeclarations.errors.txt @@ -1,13 +1,10 @@ tests/cases/compiler/semicolonsInModuleDeclarations.ts(2,27): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/semicolonsInModuleDeclarations.ts(2,27): error TS1036: Statements are not allowed in ambient contexts. -==== tests/cases/compiler/semicolonsInModuleDeclarations.ts (2 errors) ==== +==== tests/cases/compiler/semicolonsInModuleDeclarations.ts (1 errors) ==== declare module ambiModule { export interface i1 { }; ~ -!!! error TS1036: Statements are not allowed in ambient contexts. - ~ !!! error TS1036: Statements are not allowed in ambient contexts. export interface i2 { } } From 9c9bd343529e1bc33cb9218021ea34bad1a35af5 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 16 Dec 2014 19:40:22 -0800 Subject: [PATCH 72/74] Address code review --- src/compiler/checker.ts | 128 ++++++++---------- .../MemberFunctionDeclaration3_es6.errors.txt | 5 +- .../ambientWithStatements.errors.txt | 5 +- ...omputedPropertyNamesOnOverloads.errors.txt | 8 +- .../parserBreakStatement1.d.errors.txt | 7 +- .../parserComputedPropertyName11.errors.txt | 5 +- .../parserComputedPropertyName14.errors.txt | 7 +- .../parserComputedPropertyName18.errors.txt | 7 +- .../parserComputedPropertyName20.errors.txt | 5 +- .../parserComputedPropertyName23.errors.txt | 5 +- .../parserComputedPropertyName32.errors.txt | 5 +- .../parserContinueStatement1.d.errors.txt | 7 +- ...parserES5ComputedPropertyName11.errors.txt | 5 +- .../parserReturnStatement1.d.errors.txt | 7 +- 14 files changed, 77 insertions(+), 129 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2f45f5bdfbf..c86906ca5b6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7113,9 +7113,9 @@ module ts { // or if its FunctionBody is strict code(11.1.5). // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) - if (!checkGrammarModifiers(node)) { - checkGrammarEvalOrArgumentsInStrictMode(node, node.name); - } + + // Grammar checking + checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, node.name); checkVariableLikeDeclaration(node); var func = getContainingFunction(node); @@ -7218,11 +7218,7 @@ module ts { function checkMethodDeclaration(node: MethodDeclaration) { // Grammar checking - checkGrammarMethod(node); - - if (node.name.kind === SyntaxKind.ComputedPropertyName) { - checkGrammarComputedPropertyName(node.name); - } + checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); @@ -7317,12 +7313,7 @@ module ts { function checkAccessorDeclaration(node: AccessorDeclaration) { // Grammar checking accessors - checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node); - - // Grammar checking if name is a computed-property - if (node.name.kind === SyntaxKind.ComputedPropertyName) { - checkGrammarComputedPropertyName(node.name); - } + checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); if (fullTypeCheck) { if (node.kind === SyntaxKind.GetAccessor) { @@ -8101,8 +8092,7 @@ module ts { function checkForStatement(node: ForStatement) { // Grammar checking - checkGrammarForStatementInAmbientContext(node); - checkGrammarVariableDeclarations(node, node.declarations); + checkGrammarForStatementInAmbientContext(node) || checkGrammarVariableDeclarations(node, node.declarations); if (node.declarations) forEach(node.declarations, checkVariableLikeDeclaration); if (node.initializer) checkExpression(node.initializer); @@ -8112,13 +8102,13 @@ module ts { } function checkForInStatement(node: ForInStatement) { - // Grammar checkingcheck - checkGrammarForStatementInAmbientContext(node); - - 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); + // Grammar checking + if (!checkGrammarForStatementInAmbientContext(node)) { + 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); + } } } @@ -8164,8 +8154,7 @@ module ts { function checkBreakOrContinueStatement(node: BreakOrContinueStatement) { // Grammar checking - checkGrammarForStatementInAmbientContext(node); - checkGrammarBreakOrContinueStatement(node); + checkGrammarForStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); // TODO: Check that target label is valid } @@ -8176,12 +8165,11 @@ module ts { function checkReturnStatement(node: ReturnStatement) { // Grammar checking - checkGrammarForStatementInAmbientContext(node); - var parent = node.parent; - var inFunctionBlock = false; - var functionBlock = getContainingFunction(node); - if (!functionBlock) { - grammarErrorOnFirstToken(node, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); + if (!checkGrammarForStatementInAmbientContext(node)) { + var functionBlock = getContainingFunction(node); + if (!functionBlock) { + grammarErrorOnFirstToken(node, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); + } } if (node.expression) { @@ -8208,10 +8196,10 @@ module ts { function checkWithStatement(node: WithStatement) { // Grammar checking for withStatement - checkGrammarForStatementInAmbientContext(node); - - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); + if (!checkGrammarForStatementInAmbientContext(node)) { + if (node.parserContextFlags & ParserContextFlags.StrictMode) { + grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); + } } checkExpression(node.expression); @@ -8257,18 +8245,19 @@ module ts { function checkLabeledStatement(node: LabeledStatement) { // Grammar checking - checkGrammarForStatementInAmbientContext(node); - var current = node.parent; - while (current) { - if (isAnyFunction(current)) { - break; + if (!checkGrammarForStatementInAmbientContext(node)) { + var current = node.parent; + while (current) { + if (isAnyFunction(current)) { + break; + } + if (current.kind === SyntaxKind.LabeledStatement && (current).label.text === node.label.text) { + var sourceFile = getSourceFileOfNode(node); + grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceFile.text, node.label)); + break; + } + current = current.parent; } - if (current.kind === SyntaxKind.LabeledStatement && (current).label.text === node.label.text) { - var sourceFile = getSourceFileOfNode(node); - grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceFile.text, node.label)); - break; - } - current = current.parent; } // ensure that label is unique @@ -8277,11 +8266,10 @@ module ts { function checkThrowStatement(node: ThrowStatement) { // Grammar checking - checkGrammarForStatementInAmbientContext(node) - - // Type checking - if (node.expression === undefined) { - grammarErrorAfterFirstToken(node, Diagnostics.Line_break_not_permitted_here); + if (!checkGrammarForStatementInAmbientContext(node)) { + if (node.expression === undefined) { + grammarErrorAfterFirstToken(node, Diagnostics.Line_break_not_permitted_here); + } } if (node.expression) { @@ -9018,9 +9006,7 @@ module ts { function checkExportAssignment(node: ExportAssignment) { // Grammar checking - checkGrammarModifiers(node); - - if (node.flags & NodeFlags.Modifier) { + if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) { grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers); } @@ -9123,9 +9109,11 @@ module ts { case SyntaxKind.ExportAssignment: return checkExportAssignment(node); case SyntaxKind.EmptyStatement: - return checkGrammarForStatementInAmbientContext(node); + checkGrammarForStatementInAmbientContext(node); + return; case SyntaxKind.DebuggerStatement: - return checkGrammarForStatementInAmbientContext(node); + checkGrammarForStatementInAmbientContext(node); + return; } } @@ -10292,17 +10280,22 @@ module ts { return false; } - function checkGrammarComputedPropertyName(node: ComputedPropertyName): void { + function checkGrammarComputedPropertyName(node: Node): void { + // If node is not a computedPropertyName, just skip the grammar checking + if (node.kind !== SyntaxKind.ComputedPropertyName) { + return; + } // Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4 // Once full support is added, remove this error. grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_not_currently_supported); return; + var computedPropertyName = node; if (compilerOptions.target < ScriptTarget.ES6) { grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); } - else if (node.expression.kind === SyntaxKind.BinaryExpression && (node.expression).operator === SyntaxKind.CommaToken) { - grammarErrorOnNode(node.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); + else if (computedPropertyName.expression.kind === SyntaxKind.BinaryExpression && (computedPropertyName.expression).operator === SyntaxKind.CommaToken) { + grammarErrorOnNode(computedPropertyName.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } @@ -10334,10 +10327,9 @@ module ts { for (var i = 0, n = node.properties.length; i < n; i++) { var prop = node.properties[i]; var name = prop.name; - if (prop.kind === SyntaxKind.OmittedExpression) { - continue; - } - else if (name.kind === SyntaxKind.ComputedPropertyName) { + if (prop.kind === SyntaxKind.OmittedExpression || + name.kind === SyntaxKind.ComputedPropertyName) { + // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); continue; } @@ -10785,19 +10777,17 @@ module ts { return isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } - function checkGrammarForStatementInAmbientContext(node: Node): void { + function checkGrammarForStatementInAmbientContext(node: Node): boolean { if (isInAmbientContext(node)) { // An accessors is already reported about the ambient context if (isAccessor(node.parent.kind)) { - getNodeLinks(node).hasReportedStatementInAmbientContext = true; - return; + return getNodeLinks(node).hasReportedStatementInAmbientContext = true; } // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && isAnyFunction(node.parent)) { - getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts) - return; + return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts) } // We are either parented by another statement, or some sort of block. @@ -10809,7 +10799,7 @@ module ts { var links = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links.hasReportedStatementInAmbientContext) { - links.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.Statements_are_not_allowed_in_ambient_contexts); + return links.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.Statements_are_not_allowed_in_ambient_contexts); } } else { diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt index ef45ee3f9cb..b43e266e2a5 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt @@ -1,12 +1,9 @@ tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: Generators are not currently supported. -tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,5): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (2 errors) ==== +==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (1 errors) ==== class C { *[foo]() { } ~ !!! error TS9001: Generators are not currently supported. - ~~~~~ -!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/ambientWithStatements.errors.txt b/tests/baselines/reference/ambientWithStatements.errors.txt index 2179b3efb04..023dd65f56d 100644 --- a/tests/baselines/reference/ambientWithStatements.errors.txt +++ b/tests/baselines/reference/ambientWithStatements.errors.txt @@ -1,18 +1,15 @@ tests/cases/compiler/ambientWithStatements.ts(2,5): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/ambientWithStatements.ts(2,5): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. tests/cases/compiler/ambientWithStatements.ts(3,5): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. tests/cases/compiler/ambientWithStatements.ts(7,15): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter. tests/cases/compiler/ambientWithStatements.ts(11,5): error TS1108: A 'return' statement can only be used within a function body. tests/cases/compiler/ambientWithStatements.ts(25,11): error TS2410: All symbols within a 'with' block will be resolved to 'any'. -==== tests/cases/compiler/ambientWithStatements.ts (6 errors) ==== +==== tests/cases/compiler/ambientWithStatements.ts (5 errors) ==== declare module M { break; ~~~~~ !!! error TS1036: Statements are not allowed in ambient contexts. - ~~~~~~ -!!! error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. continue; ~~~~~~~~~ !!! error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt index edd7a19a957..6329ab39f0f 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads.errors.txt @@ -1,24 +1,18 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(4,5): error TS1168: Computed property names are not allowed in method overloads. -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(4,5): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(5,5): error TS1168: Computed property names are not allowed in method overloads. -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(5,5): error TS9002: Computed property names are not currently supported. tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts(6,5): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (5 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads.ts (3 errors) ==== var methodName = "method"; var accessorName = "accessor"; class C { [methodName](v: string); ~~~~~~~~~~~~ !!! error TS1168: Computed property names are not allowed in method overloads. - ~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. [methodName](); ~~~~~~~~~~~~ !!! error TS1168: Computed property names are not allowed in method overloads. - ~~~~~~~~~~~~ -!!! error TS9002: Computed property names are not currently supported. [methodName](v?: string) { } ~~~~~~~~~~~~ !!! error TS9002: Computed property names are not currently supported. diff --git a/tests/baselines/reference/parserBreakStatement1.d.errors.txt b/tests/baselines/reference/parserBreakStatement1.d.errors.txt index b6f92ee8388..a930d5a0124 100644 --- a/tests/baselines/reference/parserBreakStatement1.d.errors.txt +++ b/tests/baselines/reference/parserBreakStatement1.d.errors.txt @@ -1,10 +1,7 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserBreakStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/conformance/parser/ecmascript5/Statements/parserBreakStatement1.d.ts(1,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserBreakStatement1.d.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserBreakStatement1.d.ts (1 errors) ==== break; ~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. - ~~~~~~ -!!! error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. \ No newline at end of file +!!! error TS1036: Statements are not allowed in ambient contexts. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName11.errors.txt b/tests/baselines/reference/parserComputedPropertyName11.errors.txt index 728d10e59d3..f47aa75031d 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -1,12 +1,9 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1168: Computed property names are not allowed in method overloads. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts (1 errors) ==== class C { [e](); ~~~ !!! error TS1168: Computed property names are not allowed in method overloads. - ~~~ -!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName14.errors.txt b/tests/baselines/reference/parserComputedPropertyName14.errors.txt index e935314b4f1..d2f7ad34ed9 100644 --- a/tests/baselines/reference/parserComputedPropertyName14.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName14.errors.txt @@ -1,10 +1,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1170: Computed property names are not allowed in type literals. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts (1 errors) ==== var v: { [e](): number }; ~~~ -!!! error TS1170: Computed property names are not allowed in type literals. - ~~~ -!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file +!!! error TS1170: Computed property names are not allowed in type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName18.errors.txt b/tests/baselines/reference/parserComputedPropertyName18.errors.txt index 8539a568389..72833dda837 100644 --- a/tests/baselines/reference/parserComputedPropertyName18.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName18.errors.txt @@ -1,10 +1,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1170: Computed property names are not allowed in type literals. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts (1 errors) ==== var v: { [e]?(): number }; ~~~ -!!! error TS1170: Computed property names are not allowed in type literals. - ~~~ -!!! error TS9002: Computed property names are not currently supported. \ No newline at end of file +!!! error TS1170: Computed property names are not allowed in type literals. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName20.errors.txt b/tests/baselines/reference/parserComputedPropertyName20.errors.txt index e743e7f94b5..36a7e2d4866 100644 --- a/tests/baselines/reference/parserComputedPropertyName20.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName20.errors.txt @@ -1,12 +1,9 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: Computed property names are not allowed in interfaces. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts (1 errors) ==== interface I { [e](): number ~~~ !!! error TS1169: Computed property names are not allowed in interfaces. - ~~~ -!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName23.errors.txt b/tests/baselines/reference/parserComputedPropertyName23.errors.txt index 317f198e4d4..2018032ef94 100644 --- a/tests/baselines/reference/parserComputedPropertyName23.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName23.errors.txt @@ -1,12 +1,9 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts(2,9): error TS1086: An accessor cannot be declared in an ambient context. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts(2,9): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName23.ts (1 errors) ==== declare class C { get [e](): number ~~~ !!! error TS1086: An accessor cannot be declared in an ambient context. - ~~~ -!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName32.errors.txt b/tests/baselines/reference/parserComputedPropertyName32.errors.txt index 7aba423d690..4407014cf99 100644 --- a/tests/baselines/reference/parserComputedPropertyName32.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName32.errors.txt @@ -1,12 +1,9 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1165: Computed property names are not allowed in an ambient context. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts (1 errors) ==== declare class C { [e](): number ~~~ !!! error TS1165: Computed property names are not allowed in an ambient context. - ~~~ -!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserContinueStatement1.d.errors.txt b/tests/baselines/reference/parserContinueStatement1.d.errors.txt index f16e32987a2..a143922a761 100644 --- a/tests/baselines/reference/parserContinueStatement1.d.errors.txt +++ b/tests/baselines/reference/parserContinueStatement1.d.errors.txt @@ -1,10 +1,7 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserContinueStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/conformance/parser/ecmascript5/Statements/parserContinueStatement1.d.ts(1,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserContinueStatement1.d.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserContinueStatement1.d.ts (1 errors) ==== continue; ~~~~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. - ~~~~~~~~~ -!!! error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. \ No newline at end of file +!!! error TS1036: Statements are not allowed in ambient contexts. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt index 1e4a532d132..124db7da75a 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt @@ -1,12 +1,9 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1168: Computed property names are not allowed in method overloads. -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS9002: Computed property names are not currently supported. -==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts (1 errors) ==== class C { [e](); ~~~ !!! error TS1168: Computed property names are not allowed in method overloads. - ~~~ -!!! error TS9002: Computed property names are not currently supported. } \ No newline at end of file diff --git a/tests/baselines/reference/parserReturnStatement1.d.errors.txt b/tests/baselines/reference/parserReturnStatement1.d.errors.txt index 097a19a2bfe..844be85439e 100644 --- a/tests/baselines/reference/parserReturnStatement1.d.errors.txt +++ b/tests/baselines/reference/parserReturnStatement1.d.errors.txt @@ -1,10 +1,7 @@ tests/cases/conformance/parser/ecmascript5/Statements/parserReturnStatement1.d.ts(1,1): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/conformance/parser/ecmascript5/Statements/parserReturnStatement1.d.ts(1,1): error TS1108: A 'return' statement can only be used within a function body. -==== tests/cases/conformance/parser/ecmascript5/Statements/parserReturnStatement1.d.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/Statements/parserReturnStatement1.d.ts (1 errors) ==== return; ~~~~~~ -!!! error TS1036: Statements are not allowed in ambient contexts. - ~~~~~~ -!!! error TS1108: A 'return' statement can only be used within a function body. \ No newline at end of file +!!! error TS1036: Statements are not allowed in ambient contexts. \ No newline at end of file From c2b03b6384375ee65cc0bfd97b7a1dfaca1087f4 Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 16 Dec 2014 19:53:42 -0800 Subject: [PATCH 73/74] Address code review --- src/compiler/diagnosticInformationMap.generated.ts | 2 -- src/compiler/diagnosticMessages.json | 10 ---------- .../compiler/constDeclarations-invalidContexts.ts | 2 +- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 55399deaabe..8e0d6ce8e98 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -32,7 +32,6 @@ module ts { super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names.", isEarly: true }, Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts.", isEarly: true }, - A_function_implementation_cannot_be_declared_in_an_ambient_context: { code: 1037, category: DiagnosticCategory.Error, key: "A function implementation cannot be declared in an ambient context.", isEarly: true }, A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context.", isEarly: true }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts.", isEarly: true }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element.", isEarly: true }, @@ -74,7 +73,6 @@ module ts { A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body.", isEarly: true }, Expression_expected: { code: 1109, category: DiagnosticCategory.Error, key: "Expression expected.", isEarly: true }, Type_expected: { code: 1110, category: DiagnosticCategory.Error, key: "Type expected.", isEarly: true }, - A_constructor_implementation_cannot_be_declared_in_an_ambient_context: { code: 1111, category: DiagnosticCategory.Error, key: "A constructor implementation cannot be declared in an ambient context.", isEarly: true }, A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional.", isEarly: true }, A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement.", isEarly: true }, Duplicate_label_0: { code: 1114, category: DiagnosticCategory.Error, key: "Duplicate label '{0}'", isEarly: true }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fb3e50e3065..e5c8ba1a258 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -138,11 +138,6 @@ "code": 1036, "isEarly": true }, - "A function implementation cannot be declared in an ambient context.": { - "category": "Error", - "code": 1037, - "isEarly": true - }, "A 'declare' modifier cannot be used in an already ambient context.": { "category": "Error", "code": 1038, @@ -345,11 +340,6 @@ "code": 1110, "isEarly": true }, - "A constructor implementation cannot be declared in an ambient context.": { - "category": "Error", - "code": 1111, - "isEarly": true - }, "A class member cannot be declared optional.": { "category": "Error", "code": 1112, diff --git a/tests/cases/compiler/constDeclarations-invalidContexts.ts b/tests/cases/compiler/constDeclarations-invalidContexts.ts index 3da91a7d1d7..b5093180990 100644 --- a/tests/cases/compiler/constDeclarations-invalidContexts.ts +++ b/tests/cases/compiler/constDeclarations-invalidContexts.ts @@ -15,7 +15,7 @@ while (true); var obj; with (obj) - const c5 = 0; + const c5 = 0; // No Error will be reported here since we turn off all type checking for (var i = 0; i < 10; i++) const c6 = 0; From 99a189936f2c7449bb6ad2c52190f18f59bdc3de Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 16 Dec 2014 19:59:16 -0800 Subject: [PATCH 74/74] Remove last vestiges of the grammar checker from the parser now that it has been entirely moved to the TypeChecker. --- src/compiler/parser.ts | 1315 +---------------- src/compiler/types.ts | 6 +- ...nstDeclarations-invalidContexts.errors.txt | 2 +- 3 files changed, 24 insertions(+), 1299 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d2e8000a2fd..d4dc86dd89e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -772,7 +772,7 @@ module ts { if (token === SyntaxKind.YieldKeyword && inYieldContext()) { return false; } - + return inStrictModeContext() ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord; } @@ -948,7 +948,7 @@ module ts { parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); } - + function parseContextualModifier(t: SyntaxKind): boolean { return token === t && tryParse(nextTokenCanFollowModifier); } @@ -1029,7 +1029,7 @@ module ts { nextToken(); return isIdentifier(); } - + function isNotHeritageClauseTypeName(): boolean { if (token === SyntaxKind.ImplementsKeyword || token === SyntaxKind.ExtendsKeyword) { @@ -1301,12 +1301,12 @@ module ts { var templateSpans = >[]; templateSpans.pos = getNodePos(); - + do { templateSpans.push(parseTemplateSpan()); } while (templateSpans[templateSpans.length - 1].literal.kind === SyntaxKind.TemplateMiddle) - + templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; @@ -1692,7 +1692,7 @@ module ts { if (lookAhead(isStartOfConstructSignature)) { return parseSignatureMember(SyntaxKind.ConstructSignature); } - // fall through. + // fall through. case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: return parsePropertyOrMethodSignature(); @@ -2339,7 +2339,7 @@ module ts { if (newPrecedence <= precedence) { break; } - + if (token === SyntaxKind.InKeyword && inDisallowInContext()) { break; } @@ -2565,7 +2565,7 @@ module ts { // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression); } function parseSuperExpression(): MemberExpression { @@ -2693,7 +2693,7 @@ module ts { ? typeArguments : undefined; } - + function canFollowTypeArgumentsInExpression(): boolean { switch (token) { case SyntaxKind.OpenParenToken: // foo( @@ -3261,7 +3261,7 @@ module ts { if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*modifiers:*/ undefined); } - // Else parse it like identifier - fall through + // Else parse it like identifier - fall through default: return parseExpressionOrLabeledStatement(); } @@ -3518,7 +3518,7 @@ module ts { modifiers.pos = modifierStart; } flags |= modifierToFlag(modifierKind); - modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); } if (modifiers) { modifiers.flags = flags; @@ -3696,9 +3696,9 @@ module ts { function parseModuleDeclaration(fullStart: number, modifiers: ModifiersArray): ModuleDeclaration { parseExpected(SyntaxKind.ModuleKeyword); - return token === SyntaxKind.StringLiteral + return token === SyntaxKind.StringLiteral ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) - : parseInternalModuleTail(fullStart, modifiers, modifiers? modifiers.flags : 0); + : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); } function isExternalModuleReference() { @@ -3754,7 +3754,7 @@ module ts { parseSemicolon(); return finishNode(node); } - + function isLetDeclaration() { // It is let declaration if in strict mode or next token is identifier on same line. // otherwise it needs to be treated like identifier @@ -3768,7 +3768,7 @@ module ts { case SyntaxKind.FunctionKeyword: return true; case SyntaxKind.LetKeyword: - return isLetDeclaration(); + return isLetDeclaration(); case SyntaxKind.ClassKeyword: case SyntaxKind.InterfaceKeyword: case SyntaxKind.EnumKeyword: @@ -3904,8 +3904,8 @@ module ts { else { var amdModuleNameRegEx = /^\/\/\/\s* 0) { - // Don't bother doing any grammar checks if there are already parser errors. - // Otherwise we may end up with too many cascading errors. - syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics); - } - else { - // No parser errors were reported. Perform our stricter grammar checks. - checkGrammar(sourceText, languageVersion, sourceFile); - syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.grammarDiagnostics); - } + // Don't bother doing any grammar checks if there are already parser errors. + // Otherwise we may end up with too many cascading errors. + syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics); } Debug.assert(syntacticDiagnostics !== undefined); @@ -3987,1274 +3980,6 @@ module ts { return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment; } - function checkGrammar(sourceText: string, languageVersion: ScriptTarget, file: SourceFile) { - return; - var grammarDiagnostics = file.grammarDiagnostics; - - // Create a scanner so we can find the start of tokens to report errors on. - var scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceText); - - // We're automatically in an ambient context if this is a .d.ts file. - var inAmbientContext = fileExtensionIs(file.filename, ".d.ts"); - var inFunctionBlock = false; - var parent: Node; - visitNode(file); - - function visitNode(node: Node): void { - // Store and restore our recursive state here. - var savedParent = parent; - node.parent = parent; - parent = node; - - if (!checkModifiers(node)) { - var savedInFunctionBlock = inFunctionBlock; - if (isFunctionBlock(node)) { - inFunctionBlock = true; - } - - var savedInAmbientContext = inAmbientContext - if (node.flags & NodeFlags.Ambient) { - inAmbientContext = true; - } - - checkNodeAndChildren(node); - - inAmbientContext = savedInAmbientContext; - inFunctionBlock = savedInFunctionBlock; - } - - parent = savedParent; - } - - function checkNodeAndChildren(node: Node) { - var nodeKind = node.kind; - // First, check if you have a statement in a place where it is not allowed. We want - // to do this before recursing, because we'd prefer to report these errors at the top - // level instead of at some nested level. - if (inAmbientContext && checkForStatementInAmbientContext(node, nodeKind)) { - return; - } - - // if we got any errors, just stop performing any more checks on this node or higher. - if (checkNode(node, nodeKind)) { - return; - } - - // Otherwise, recurse and see if we have any errors below us. - forEachChild(node, visitNode); - } - - function checkNode(node: Node, nodeKind: SyntaxKind): boolean { - // Now do node specific checks. - //switch (nodeKind) { - //case SyntaxKind.BreakStatement: - //case SyntaxKind.ContinueStatement: - //return checkBreakOrContinueStatement(node); - //case SyntaxKind.CallExpression: - //case SyntaxKind.NewExpression: - //return checkCallOrNewExpression(node); - - //case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(node); - //case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); - //case SyntaxKind.BindingElement: return checkBindingElement(node); - //case SyntaxKind.CatchClause: return checkCatchClause(node); - //case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); - //case SyntaxKind.ComputedPropertyName: return checkComputedPropertyName(node); - //case SyntaxKind.Constructor: return checkConstructor(node); - //case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); - //case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); - //case SyntaxKind.ExportAssignment: return checkExportAssignment(node); - //case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); - //case SyntaxKind.ForInStatement: return checkForInStatement(node); - //case SyntaxKind.ForStatement: return checkForStatement(node); - //case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node); - //case SyntaxKind.FunctionExpression: return checkFunctionExpression(node); - //case SyntaxKind.GetAccessor: return checkGetAccessor(node); - //case SyntaxKind.HeritageClause: return checkHeritageClause(node); - //case SyntaxKind.InterfaceDeclaration: return checkInterfaceDeclaration(node); - //case SyntaxKind.LabeledStatement: return checkLabeledStatement(node); - //case SyntaxKind.PropertyAssignment: return checkPropertyAssignment(node); - //case SyntaxKind.MethodDeclaration: - //case SyntaxKind.MethodSignature: - //return checkMethod(node); - //case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(node); - //case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(node); - //case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); - //case SyntaxKind.Parameter: return checkParameter(node); - //case SyntaxKind.PostfixUnaryExpression: return checkPostfixUnaryExpression(node); - //case SyntaxKind.PrefixUnaryExpression: return checkPrefixUnaryExpression(node); - //case SyntaxKind.PropertyDeclaration: - //case SyntaxKind.PropertySignature: - //return checkProperty(node); - //case SyntaxKind.ReturnStatement: return checkReturnStatement(node); - //case SyntaxKind.SetAccessor: return checkSetAccessor(node); - //case SyntaxKind.SourceFile: return checkSourceFile(node); - //case SyntaxKind.ShorthandPropertyAssignment: return checkShorthandPropertyAssignment(node); - //case SyntaxKind.SwitchStatement: return checkSwitchStatement(node); - //case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node); - //case SyntaxKind.ThrowStatement: return checkThrowStatement(node); - //case SyntaxKind.TypeReference: return checkTypeReference(node); - //case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); - //case SyntaxKind.VariableStatement: return checkVariableStatement(node); - //case SyntaxKind.WithStatement: return checkWithStatement(node); - //case SyntaxKind.YieldExpression: return checkYieldExpression(node); - //return false - //} - return false; - } - - function scanToken(pos: number) { - var start = skipTrivia(sourceText, pos); - scanner.setTextPos(start); - scanner.scan(); - return start; - } - - function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { - var start = scanToken(node.pos); - grammarDiagnostics.push(createFileDiagnostic(file, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); - return true; - } - - function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { - scanToken(node.pos); - grammarDiagnostics.push(createFileDiagnostic(file, scanner.getTextPos(), 0, message, arg0, arg1, arg2)); - return true; - } - - function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { - var span = getErrorSpanForNode(node); - var start = span.end > span.pos ? skipTrivia(file.text, span.pos) : span.pos; - var length = span.end - start; - - grammarDiagnostics.push(createFileDiagnostic(file, start, length, message, arg0, arg1, arg2)); - return true; - } - - function grammarErrorAtPos(start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { - grammarDiagnostics.push(createFileDiagnostic(file, start, length, message, arg0, arg1, arg2)); - return true; - } - - function reportInvalidUseInStrictMode(node: Identifier): boolean { - // declarationNameToString cannot be used here since it uses a backreference to 'parent' that is not yet set - var name = sourceText.substring(skipTrivia(sourceText, node.pos), node.end); - return grammarErrorOnNode(node, Diagnostics.Invalid_use_of_0_in_strict_mode, name); - } - - function checkForStatementInAmbientContext(node: Node, kind: SyntaxKind): boolean { - switch (kind) { - //case SyntaxKind.Block: - case SyntaxKind.EmptyStatement: - //case SyntaxKind.IfStatement: - //case SyntaxKind.DoStatement: - //case SyntaxKind.WhileStatement: - //case SyntaxKind.ForStatement: - //case SyntaxKind.ForInStatement: - //case SyntaxKind.ContinueStatement: - //case SyntaxKind.BreakStatement: - //case SyntaxKind.ReturnStatement: - //case SyntaxKind.WithStatement: - //case SyntaxKind.SwitchStatement: - //case SyntaxKind.ThrowStatement: - //case SyntaxKind.TryStatement: - case SyntaxKind.DebuggerStatement: - //case SyntaxKind.LabeledStatement: - //case SyntaxKind.ExpressionStatement: - return grammarErrorOnFirstToken(node, Diagnostics.Statements_are_not_allowed_in_ambient_contexts); - } - } - - function checkAnySignatureDeclaration(node: SignatureDeclaration): boolean { - return checkTypeParameterList(node.typeParameters) || - checkParameterList(node.parameters); - } - - function checkBinaryExpression(node: BinaryExpression) { - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) { - if (isEvalOrArgumentsIdentifier(node.left)) { - // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) - return reportInvalidUseInStrictMode(node.left); - } - } - } - } - - function isIterationStatement(node: Node, lookInLabeledStatements: boolean): boolean { - switch (node.kind) { - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - return true; - case SyntaxKind.LabeledStatement: - return lookInLabeledStatements && isIterationStatement((node).statement, lookInLabeledStatements); - } - - return false; - } - - function checkLabeledStatement(node: LabeledStatement): boolean { - // ensure that label is unique - var current = node.parent; - while (current) { - if (isAnyFunction(current)) { - break; - } - if (current.kind === SyntaxKind.LabeledStatement && (current).label.text === node.label.text) { - return grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label)); - } - current = current.parent; - } - } - - function checkBreakOrContinueStatement(node: BreakOrContinueStatement): boolean { - var current: Node = node; - while (current) { - if (isAnyFunction(current)) { - return grammarErrorOnNode(node, Diagnostics.Jump_target_cannot_cross_function_boundary); - } - - switch (current.kind) { - case SyntaxKind.LabeledStatement: - if (node.label && (current).label.text === node.label.text) { - // found matching label - verify that label usage is correct - // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === SyntaxKind.ContinueStatement - && !isIterationStatement((current).statement, /*lookInLabeledStatement*/ true); - - if (isMisplacedContinueLabel) { - return grammarErrorOnNode(node, Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); - } - - return false; - } - break; - case SyntaxKind.SwitchStatement: - if (node.kind === SyntaxKind.BreakStatement && !node.label) { - // unlabeled break within switch statement - ok - return false; - } - break; - default: - if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { - // unlabeled break or continue within iteration statement - ok - return false; - } - break; - } - - current = current.parent; - } - - if (node.label) { - var message = node.kind === SyntaxKind.BreakStatement - ? Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement - : Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; - - return grammarErrorOnNode(node, message) - } - else { - var message = node.kind === SyntaxKind.BreakStatement - ? Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement - : Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message) - } - } - - function checkCallOrNewExpression(node: CallExpression) { - return checkTypeArguments(node.typeArguments) || - checkArguments(node.arguments); - } - - function checkArguments(arguments: NodeArray) { - return checkForDisallowedTrailingComma(arguments) || - checkForOmittedArgument(arguments); - } - - function checkTypeArguments(typeArguments: NodeArray) { - return checkForDisallowedTrailingComma(typeArguments) || - checkForAtLeastOneTypeArgument(typeArguments); - } - - function checkForOmittedArgument(arguments: NodeArray) { - if (arguments) { - for (var i = 0, n = arguments.length; i < n; i++) { - var arg = arguments[i]; - if (arg.kind === SyntaxKind.OmittedExpression) { - return grammarErrorAtPos(arg.pos, 0, Diagnostics.Argument_expression_expected); - } - } - } - } - - function checkForAtLeastOneTypeArgument(typeArguments: NodeArray) { - if (typeArguments && typeArguments.length === 0) { - var start = typeArguments.pos - "<".length; - var end = skipTrivia(sourceText, typeArguments.end) + ">".length; - return grammarErrorAtPos(start, end - start, Diagnostics.Type_argument_list_cannot_be_empty); - } - } - - function checkForDisallowedTrailingComma(list: NodeArray): boolean { - if (list && list.hasTrailingComma) { - var start = list.end - ",".length; - var end = list.end; - return grammarErrorAtPos(start, end - start, Diagnostics.Trailing_comma_not_allowed); - } - } - - function checkCatchClause(node: CatchClause) { - if (node.type) { - var colonStart = skipTrivia(sourceText, node.name.end); - return grammarErrorAtPos(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 - return reportInvalidUseInStrictMode(node.name); - } - } - - function checkClassDeclaration(node: ClassDeclaration) { - return checkClassDeclarationHeritageClauses(node); - } - - function checkClassDeclarationHeritageClauses(node: ClassDeclaration): boolean { - var seenExtendsClause = false; - var seenImplementsClause = false; - - if (node.heritageClauses) { - for (var i = 0, n = node.heritageClauses.length; i < n; i++) { - Debug.assert(i <= 2); - var heritageClause = node.heritageClauses[i]; - - if (heritageClause.token === SyntaxKind.ExtendsKeyword) { - if (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen); - } - - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_must_precede_implements_clause); - } - - if (heritageClause.types.length > 1) { - return grammarErrorOnFirstToken(heritageClause.types[1], Diagnostics.Classes_can_only_extend_a_single_class); - } - - seenExtendsClause = true; - } - else { - Debug.assert(heritageClause.token === SyntaxKind.ImplementsKeyword); - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, Diagnostics.implements_clause_already_seen); - } - - seenImplementsClause = true; - } - } - } - - return false; - } - - function checkForAtLeastOneHeritageClause(types: NodeArray, listType: string): boolean { - if (types && types.length === 0) { - return grammarErrorAtPos(types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType) - } - } - - function checkConstructor(node: ConstructorDeclaration) { - return checkAnySignatureDeclaration(node) || - checkConstructorTypeParameters(node) || - checkConstructorTypeAnnotation(node) || - checkForBodyInAmbientContext(node.body, /*isConstructor:*/ true); - } - - function checkConstructorTypeParameters(node: ConstructorDeclaration) { - if (node.typeParameters) { - return grammarErrorAtPos(node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); - } - } - - function checkConstructorTypeAnnotation(node: ConstructorDeclaration) { - if (node.type) { - return grammarErrorOnNode(node.type, Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); - } - } - - function checkDeleteExpression(node: DeleteExpression) { - if (node.parserContextFlags & ParserContextFlags.StrictMode && node.expression.kind === SyntaxKind.Identifier) { - // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its - // UnaryExpression is a direct reference to a variable, function argument, or function name - return grammarErrorOnNode(node.expression, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - } - - function checkEnumDeclaration(enumDecl: EnumDeclaration): boolean { - var enumIsConst = (enumDecl.flags & NodeFlags.Const) !== 0; - - var hasError = false; - - // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. - // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - for (var i = 0, n = enumDecl.members.length; i < n; i++) { - var node = enumDecl.members[i]; - if (node.name.kind === SyntaxKind.ComputedPropertyName) { - hasError = grammarErrorOnNode(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - - return hasError; - } - - function isIntegerLiteral(expression: Expression): boolean { - function isInteger(literalExpression: LiteralExpression): boolean { - // Allows for scientific notation since literalExpression.text was formed by - // coercing a number to a string. Sometimes this coercion can yield a string - // in scientific notation. - // We also don't need special logic for hex because a hex integer is converted - // to decimal when it is coerced. - return /^[0-9]+([eE]\+?[0-9]+)?$/.test(literalExpression.text); - } - - if (expression.kind === SyntaxKind.PrefixUnaryExpression) { - var unaryExpression = expression; - if (unaryExpression.operator === SyntaxKind.PlusToken || unaryExpression.operator === SyntaxKind.MinusToken) { - expression = unaryExpression.operand; - } - } - if (expression.kind === SyntaxKind.NumericLiteral) { - return isInteger(expression); - } - - return false; - } - - function checkExportAssignment(node: ExportAssignment) { - if (node.flags & NodeFlags.Modifier) { - return grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers); - } - } - - function checkExternalModuleReference(node: ExternalModuleReference) { - if (node.expression.kind !== SyntaxKind.StringLiteral) { - return grammarErrorOnNode(node.expression, Diagnostics.String_literal_expected); - } - } - - function checkForInStatement(node: ForInStatement) { - return checkVariableDeclarations(node.declarations) || - checkForMoreThanOneDeclaration(node.declarations); - } - - function checkForStatement(node: ForStatement) { - return checkVariableDeclarations(node.declarations); - } - - function checkForMoreThanOneDeclaration(declarations: NodeArray) { - if (declarations && declarations.length > 1) { - return grammarErrorOnFirstToken(declarations[1], Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement); - } - } - - function checkFunctionDeclaration(node: FunctionLikeDeclaration) { - return checkAnySignatureDeclaration(node) || - checkFunctionName(node.name) || - checkForBodyInAmbientContext(node.body, /*isConstructor:*/ false) || - checkForGenerator(node); - } - - function checkForGenerator(node: FunctionLikeDeclaration) { - if (node.asteriskToken) { - return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_not_currently_supported); - } - } - - function checkFunctionExpression(node: FunctionExpression) { - return checkAnySignatureDeclaration(node) || - checkFunctionName(node.name) || - checkForGenerator(node); - } - - function checkFunctionName(name: Node) { - if (name && name.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(name)) { - // It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the - // Identifier of a FunctionLikeDeclaration or FunctionExpression or as a formal parameter name(13.1) - return reportInvalidUseInStrictMode(name); - } - } - - function checkGetAccessor(node: MethodDeclaration) { - return checkAnySignatureDeclaration(node) || - checkAccessor(node); - } - - function checkElementAccessExpression(node: ElementAccessExpression) { - if (!node.argumentExpression) { - if (node.parent.kind === SyntaxKind.NewExpression && (node.parent).expression === node) { - var start = skipTrivia(sourceText, node.expression.end); - var end = node.end; - return grammarErrorAtPos(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; - return grammarErrorAtPos(start, end - start, Diagnostics.Expression_expected); - } - } - } - - function checkHeritageClause(node: HeritageClause): boolean { - return checkForDisallowedTrailingComma(node.types) || - checkForAtLeastOneHeritageClause(node.types, tokenToString(node.token)); - } - - function checkIndexSignature(node: SignatureDeclaration): boolean { - return checkIndexSignatureParameters(node) || - checkForIndexSignatureModifiers(node); - } - - function checkForIndexSignatureModifiers(node: SignatureDeclaration): boolean { - if (node.flags & NodeFlags.Modifier) { - return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_not_permitted_on_index_signature_members); - } - } - - function checkIndexSignatureParameters(node: SignatureDeclaration): boolean { - var parameter = node.parameters[0]; - if (node.parameters.length !== 1) { - if (parameter) { - return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - else { - return grammarErrorOnNode(node, Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - } - else if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.An_index_signature_cannot_have_a_rest_parameter); - } - else if (parameter.flags & NodeFlags.Modifier) { - return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); - } - else if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); - } - else if (!parameter.type) { - return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); - } - else if (parameter.type.kind !== SyntaxKind.StringKeyword && parameter.type.kind !== SyntaxKind.NumberKeyword) { - return grammarErrorOnNode(parameter.name, Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); - } - else if (!node.type) { - return grammarErrorOnNode(node, Diagnostics.An_index_signature_must_have_a_type_annotation); - } - } - - function checkInterfaceDeclaration(node: InterfaceDeclaration) { - return checkInterfaceDeclarationHeritageClauses(node); - } - - function checkInterfaceDeclarationHeritageClauses(node: InterfaceDeclaration): boolean { - var seenExtendsClause = false; - - if (node.heritageClauses) { - for (var i = 0, n = node.heritageClauses.length; i < n; i++) { - Debug.assert(i <= 1); - var heritageClause = node.heritageClauses[i]; - - if (heritageClause.token === SyntaxKind.ExtendsKeyword) { - if (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, Diagnostics.extends_clause_already_seen); - } - - seenExtendsClause = true; - } - else { - Debug.assert(heritageClause.token === SyntaxKind.ImplementsKeyword); - return grammarErrorOnFirstToken(heritageClause, Diagnostics.Interface_declaration_cannot_have_implements_clause); - } - } - } - - return false; - } - - function checkMethod(node: MethodDeclaration) { - if (checkAnySignatureDeclaration(node) || - checkForBodyInAmbientContext(node.body, /*isConstructor:*/ false) || - checkForGenerator(node)) { - return true; - } - - if (node.parent.kind === SyntaxKind.ClassDeclaration) { - if (checkForInvalidQuestionMark(node, node.questionToken, Diagnostics.A_class_member_cannot_be_declared_optional)) { - return true; - } - // Technically, computed properties in ambient contexts is disallowed - // for property declarations and accessors too, not just methods. - // However, property declarations disallow computed names in general, - // and accessors are not allowed in ambient contexts in general, - // so this error only really matters for methods. - if (inAmbientContext) { - return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context); - } - else if (!node.body) { - return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_method_overloads); - } - } - else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) { - return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces); - } - else if (node.parent.kind === SyntaxKind.TypeLiteral) { - return checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_type_literals); - } - } - - function checkForBodyInAmbientContext(body: Block | Expression, isConstructor: boolean): boolean { - if (inAmbientContext && body && body.kind === SyntaxKind.Block) { - var diagnostic = isConstructor - ? Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context - : Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; - return grammarErrorOnFirstToken(body, diagnostic); - } - } - - function checkModuleDeclaration(node: ModuleDeclaration): boolean { - return checkModuleDeclarationName(node) || - checkModuleDeclarationStatements(node); - } - - function checkModuleDeclarationName(node: ModuleDeclaration) { - if (!inAmbientContext && node.name.kind === SyntaxKind.StringLiteral) { - return grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names); - } - } - - function checkModuleDeclarationStatements(node: ModuleDeclaration): boolean { - if (node.name.kind === SyntaxKind.Identifier && node.body.kind === SyntaxKind.ModuleBlock) { - var statements = (node.body).statements; - for (var i = 0, n = statements.length; i < n; i++) { - var statement = statements[i]; - - if (statement.kind === SyntaxKind.ExportAssignment) { - // Export assignments are not allowed in an internal module - return grammarErrorOnNode(statement, Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); - } - else if (isExternalModuleImportDeclaration(statement)) { - return grammarErrorOnNode(getExternalModuleImportDeclarationExpression(statement), Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); - } - } - } - } - - function checkObjectLiteralExpression(node: ObjectLiteralExpression): boolean { - var seen: Map = {}; - var Property = 1; - var GetAccessor = 2; - var SetAccesor = 4; - var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.parserContextFlags & ParserContextFlags.StrictMode) !== 0; - - for (var i = 0, n = node.properties.length; i < n; i++) { - var prop = node.properties[i]; - var name = prop.name; - if (prop.kind === SyntaxKind.OmittedExpression || name.kind === SyntaxKind.ComputedPropertyName) { - continue; - } - - // ECMA-262 11.1.5 Object Initialiser - // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true - // a.This production is contained in strict code and IsDataDescriptor(previous) is true and - // IsDataDescriptor(propId.descriptor) is true. - // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. - // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. - // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true - // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind: number; - if (prop.kind === SyntaxKind.PropertyAssignment || - prop.kind === SyntaxKind.ShorthandPropertyAssignment || - prop.kind === SyntaxKind.MethodDeclaration) { - currentKind = Property; - } - else if (prop.kind === SyntaxKind.GetAccessor) { - currentKind = GetAccessor; - } - else if (prop.kind === SyntaxKind.SetAccessor) { - currentKind = SetAccesor; - } - else { - Debug.fail("Unexpected syntax kind:" + prop.kind); - } - - if (!hasProperty(seen, name.text)) { - seen[name.text] = currentKind; - } - else { - var existingKind = seen[name.text]; - if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } - } - else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { - if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name.text] = currentKind | existingKind; - } - else { - return grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); - } - } - else { - return grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); - } - } - } - } - - function checkNumericLiteral(node: LiteralExpression): boolean { - if (node.flags & NodeFlags.OctalLiteral) { - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= ScriptTarget.ES5) { - return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } - } - } - - function checkModifiers(node: Node): boolean { - switch (node.kind) { - //case SyntaxKind.GetAccessor: - //case SyntaxKind.SetAccessor: - //case SyntaxKind.Constructor: - //case SyntaxKind.PropertyDeclaration: - //case SyntaxKind.PropertySignature: - //case SyntaxKind.MethodDeclaration: - //case SyntaxKind.MethodSignature: - //case SyntaxKind.ClassDeclaration: - //case SyntaxKind.InterfaceDeclaration: - //case SyntaxKind.ModuleDeclaration: - //case SyntaxKind.EnumDeclaration: - case SyntaxKind.ExportAssignment: - //case SyntaxKind.VariableStatement: - //case SyntaxKind.FunctionDeclaration: - case SyntaxKind.TypeAliasDeclaration: - case SyntaxKind.ImportDeclaration: - //case SyntaxKind.Parameter: - break; - default: - return false; - } - - if (!node.modifiers) { - return; - } - - var lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node; - var flags = 0; - for (var i = 0, n = node.modifiers.length; i < n; i++) { - var modifier = node.modifiers[i]; - - switch (modifier.kind) { - case SyntaxKind.PublicKeyword: - case SyntaxKind.ProtectedKeyword: - case SyntaxKind.PrivateKeyword: - var text: string; - if (modifier.kind === SyntaxKind.PublicKeyword) { - text = "public"; - } - else if (modifier.kind === SyntaxKind.ProtectedKeyword) { - text = "protected"; - lastProtected = modifier; - } - else { - text = "private"; - lastPrivate = modifier; - } - - if (flags & NodeFlags.AccessibilityModifier) { - return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen); - } - else if (flags & NodeFlags.Static) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); - } - else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); - } - flags |= modifierToFlag(modifier.kind); - break; - - case SyntaxKind.StaticKeyword: - if (flags & NodeFlags.Static) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "static"); - } - else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); - } - else if (node.kind === SyntaxKind.Parameter) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); - } - flags |= NodeFlags.Static; - lastStatic = modifier; - break; - - case SyntaxKind.ExportKeyword: - if (flags & NodeFlags.Export) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "export"); - } - else if (flags & NodeFlags.Ambient) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); - } - else if (node.parent.kind === SyntaxKind.ClassDeclaration) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); - } - else if (node.kind === SyntaxKind.Parameter) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); - } - flags |= NodeFlags.Export; - break; - - case SyntaxKind.DeclareKeyword: - if (flags & NodeFlags.Ambient) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "declare"); - } - else if (node.parent.kind === SyntaxKind.ClassDeclaration) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); - } - else if (node.kind === SyntaxKind.Parameter) { - return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); - } - else if (inAmbientContext && node.parent.kind === SyntaxKind.ModuleBlock) { - return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); - } - flags |= NodeFlags.Ambient; - lastDeclare = modifier; - break; - } - } - - if (node.kind === SyntaxKind.Constructor) { - if (flags & NodeFlags.Static) { - return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); - } - else if (flags & NodeFlags.Protected) { - return grammarErrorOnNode(lastProtected, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); - } - else if (flags & NodeFlags.Private) { - return grammarErrorOnNode(lastPrivate, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); - } - } - else if (node.kind === SyntaxKind.ImportDeclaration && flags & NodeFlags.Ambient) { - return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); - } - else if (node.kind === SyntaxKind.InterfaceDeclaration && flags & NodeFlags.Ambient) { - return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); - } - } - - function checkParameter(node: ParameterDeclaration): boolean { - // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the - // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code - // or if its FunctionBody is strict code(11.1.5). - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) - if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.name)) { - return reportInvalidUseInStrictMode(node.name); - } - } - - function checkTypeParameterList(typeParameters: NodeArray): boolean { - if (checkForDisallowedTrailingComma(typeParameters)) { - return true; - } - - if (typeParameters && typeParameters.length === 0) { - var start = typeParameters.pos - "<".length; - var end = skipTrivia(sourceText, typeParameters.end) + ">".length; - return grammarErrorAtPos(start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty); - } - } - - function checkParameterList(parameters: NodeArray): boolean { - if (checkForDisallowedTrailingComma(parameters)) { - return true; - } - - var seenOptionalParameter = false; - var parameterCount = parameters.length; - - for (var i = 0; i < parameterCount; i++) { - var parameter = parameters[i]; - if (parameter.dotDotDotToken) { - if (i !== (parameterCount - 1)) { - return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); - } - - if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, Diagnostics.A_rest_parameter_cannot_be_optional); - } - - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_have_an_initializer); - } - } - else if (parameter.questionToken || parameter.initializer) { - seenOptionalParameter = true; - - if (parameter.questionToken && parameter.initializer) { - return grammarErrorOnNode(parameter.name, Diagnostics.Parameter_cannot_have_question_mark_and_initializer); - } - } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } - } - } - } - - function checkPostfixUnaryExpression(node: PostfixUnaryExpression) { - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. - if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.operand)) { - return reportInvalidUseInStrictMode(node.operand); - } - } - - function checkPrefixUnaryExpression(node: PrefixUnaryExpression) { - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator - if ((node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) && isEvalOrArgumentsIdentifier(node.operand)) { - return reportInvalidUseInStrictMode(node.operand); - } - } - } - - function checkProperty(node: PropertyDeclaration) { - if (node.parent.kind === SyntaxKind.ClassDeclaration) { - if (checkForInvalidQuestionMark(node, node.questionToken, Diagnostics.A_class_member_cannot_be_declared_optional) || - checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_class_property_declarations)) { - return true; - } - } - else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) { - if (checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_interfaces)) { - return true; - } - } - else if (node.parent.kind === SyntaxKind.TypeLiteral) { - if (checkForDisallowedComputedProperty(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_type_literals)) { - return true; - } - } - - return checkForInitializerInAmbientContext(node); - } - - function checkComputedPropertyName(node: ComputedPropertyName) { - // Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4 - // Once full support is added, remove this error. - return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_not_currently_supported); - - if (languageVersion < ScriptTarget.ES6) { - return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - else if (node.expression.kind === SyntaxKind.BinaryExpression && (node.expression).operator === SyntaxKind.CommaToken) { - return grammarErrorOnNode(node.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); - } - } - - function checkForDisallowedComputedProperty(node: DeclarationName, message: DiagnosticMessage) { - if (node.kind === SyntaxKind.ComputedPropertyName) { - return grammarErrorOnNode(node, message); - } - } - - function checkForInitializerInAmbientContext(node: PropertyDeclaration) { - if (inAmbientContext && node.initializer) { - return grammarErrorOnFirstToken(node.initializer, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - - function checkPropertyAssignment(node: PropertyAssignment) { - return checkForInvalidQuestionMark(node, node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); - } - - function checkForInvalidQuestionMark(node: Declaration, questionToken: Node, message: DiagnosticMessage) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } - } - - function checkReturnStatement(node: ReturnStatement) { - if (!inFunctionBlock) { - return grammarErrorOnFirstToken(node, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); - } - } - - function checkSetAccessor(node: MethodDeclaration) { - return checkAnySignatureDeclaration(node) || - checkAccessor(node); - } - - function checkAccessor(accessor: MethodDeclaration): boolean { - var kind = accessor.kind; - if (languageVersion < ScriptTarget.ES5) { - return grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (inAmbientContext) { - return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined) { - return grammarErrorAtPos(accessor.end - 1, ";".length, Diagnostics._0_expected, "{"); - } - else if (accessor.typeParameters) { - return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_have_type_parameters); - } - else if (kind === SyntaxKind.GetAccessor && accessor.parameters.length) { - return grammarErrorOnNode(accessor.name, Diagnostics.A_get_accessor_cannot_have_parameters); - } - else if (kind === SyntaxKind.SetAccessor) { - if (accessor.type) { - return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); - } - else if (accessor.parameters.length !== 1) { - return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_must_have_exactly_one_parameter); - } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.flags & NodeFlags.Modifier) { - return grammarErrorOnNode(accessor.name, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } - } - } - } - - function checkSourceFile(node: SourceFile): boolean { - return inAmbientContext && checkTopLevelElementsForRequiredDeclareModifier(file); - } - - function checkTopLevelElementsForRequiredDeclareModifier(file: SourceFile): boolean { - for (var i = 0, n = file.statements.length; i < n; i++) { - var decl = file.statements[i]; - if (isDeclaration(decl) || decl.kind === SyntaxKind.VariableStatement) { - if (checkTopLevelElementForRequiredDeclareModifier(decl)) { - return true; - } - } - } - } - - function checkTopLevelElementForRequiredDeclareModifier(node: Node): boolean { - // A declare modifier is required for any top level .d.ts declaration except export=, interfaces and imports: - // categories: - // - // DeclarationElement: - // ExportAssignment - // export_opt InterfaceDeclaration - // export_opt ImportDeclaration - // export_opt ExternalImportDeclaration - // export_opt AmbientDeclaration - // - if (node.kind === SyntaxKind.InterfaceDeclaration || - node.kind === SyntaxKind.ImportDeclaration || - node.kind === SyntaxKind.ExportAssignment || - (node.flags & NodeFlags.Ambient)) { - - return false; - } - - return grammarErrorOnFirstToken(node, Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); - } - - function checkShorthandPropertyAssignment(node: ShorthandPropertyAssignment): boolean { - return checkForInvalidQuestionMark(node, node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); - } - - function checkSwitchStatement(node: SwitchStatement) { - var firstDefaultClause: CaseOrDefaultClause; - - // Error on duplicate 'default' clauses. - for (var i = 0, n = node.clauses.length; i < n; i++) { - var clause = node.clauses[i]; - if (clause.kind === SyntaxKind.DefaultClause) { - if (firstDefaultClause === undefined) { - firstDefaultClause = clause; - } - else { - var start = skipTrivia(file.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - return grammarErrorAtPos(start, end - start, Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); - - } - } - } - } - - function checkTaggedTemplateExpression(node: TaggedTemplateExpression) { - if (languageVersion < ScriptTarget.ES6) { - return grammarErrorOnFirstToken(node.template, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - } - - function checkThrowStatement(node: ThrowStatement) { - if (node.expression === undefined) { - return grammarErrorAfterFirstToken(node, Diagnostics.Line_break_not_permitted_here); - } - } - - function checkTupleType(node: TupleTypeNode) { - return checkForDisallowedTrailingComma(node.elementTypes) || - checkForAtLeastOneType(node); - } - - function checkForAtLeastOneType(node: TupleTypeNode): boolean { - if (node.elementTypes.length === 0) { - return grammarErrorOnNode(node, Diagnostics.A_tuple_type_element_list_cannot_be_empty) - } - } - - function checkTypeReference(node: TypeReferenceNode) { - return checkTypeArguments(node.typeArguments); - } - - function checkBindingElement(node: BindingElement) { - if (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 - return reportInvalidUseInStrictMode(node.name); - } - } - - function checkVariableDeclaration(node: VariableDeclaration) { - if (inAmbientContext) { - if (isBindingPattern(node.name)) { - return grammarErrorOnNode(node, Diagnostics.Destructuring_declarations_are_not_allowed_in_ambient_contexts); - } - if (node.initializer) { - // Error on equals token which immediate precedes the initializer - return grammarErrorAtPos(node.initializer.pos - 1, 1, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - else { - if (!node.initializer) { - if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { - return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); - } - if (isConst(node)) { - return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); - } - } - } - if (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 - return reportInvalidUseInStrictMode(node.name); - } - } - - function checkVariableDeclarations(declarations: NodeArray): boolean { - if (declarations) { - if (checkForDisallowedTrailingComma(declarations)) { - return true; - } - - if (!declarations.length) { - return grammarErrorAtPos(declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty); - } - - var decl = declarations[0]; - if (languageVersion < ScriptTarget.ES6) { - if (isLet(decl)) { - return grammarErrorOnFirstToken(decl, Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - else if (isConst(decl)) { - return grammarErrorOnFirstToken(decl, Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - } - } - } - - function checkVariableStatement(node: VariableStatement) { - return checkVariableDeclarations(node.declarations) || - checkForDisallowedLetOrConstStatement(node); - } - - function checkForDisallowedLetOrConstStatement(node: VariableStatement) { - if (!allowLetAndConstDeclarations(node.parent)) { - if (isLet(node)) { - return grammarErrorOnNode(node, Diagnostics.let_declarations_can_only_be_declared_inside_a_block); - } - else if (isConst(node)) { - return grammarErrorOnNode(node, Diagnostics.const_declarations_can_only_be_declared_inside_a_block); - } - } - } - - function allowLetAndConstDeclarations(parent: Node): boolean { - switch (parent.kind) { - case SyntaxKind.IfStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.WithStatement: - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - return false; - case SyntaxKind.LabeledStatement: - return allowLetAndConstDeclarations(parent.parent); - } - - return true; - } - - function checkWithStatement(node: WithStatement): boolean { - if (node.parserContextFlags & ParserContextFlags.StrictMode) { - // Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such - // a context is an - return grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } - - function checkYieldExpression(node: YieldExpression): boolean { - if (!(node.parserContextFlags & ParserContextFlags.Yield)) { - return grammarErrorOnFirstToken(node, Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration); - } - return grammarErrorOnFirstToken(node, Diagnostics.yield_expressions_are_not_currently_supported); - } - } - export function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program { var program: Program; var files: SourceFile[] = []; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index dda9996501f..f7e94beac6f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1221,9 +1221,9 @@ module ts { isIllegalTypeReferenceInConstraint?: boolean; // Is type reference in constraint refers to the type parameter from the same list isVisible?: boolean; // Is this node visible localModuleName?: string; // Local name for module instance - assignmentChecks?: Map; // Cache of assignment checks - hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context - importOnRightSide?: Symbol; // for import declarations - import that appear on the right side + assignmentChecks?: Map; // Cache of assignment checks + hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context + importOnRightSide?: Symbol; // for import declarations - import that appear on the right side } export const enum TypeFlags { diff --git a/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt b/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt index 87378cffe4d..20ec5b0c25b 100644 --- a/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt +++ b/tests/baselines/reference/constDeclarations-invalidContexts.errors.txt @@ -36,7 +36,7 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: with (obj) ~~~ !!! error TS2410: All symbols within a 'with' block will be resolved to 'any'. - const c5 = 0; + const c5 = 0; // No Error will be reported here since we turn off all type checking for (var i = 0; i < 10; i++) const c6 = 0;