From 94febee13874e2309be130e232ffe057ee1b025b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 1 Dec 2014 00:52:52 -0800 Subject: [PATCH] Don't create errors directly when parsing template spans. --- src/compiler/diagnosticInformationMap.generated.ts | 1 - src/compiler/diagnosticMessages.json | 4 ---- src/compiler/parser.ts | 3 +-- tests/baselines/reference/TemplateExpression1.errors.txt | 4 ++-- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 74341b9665..6b545ddfd0 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -119,7 +119,6 @@ module ts { 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." }, - Invalid_template_literal_expected: { code: 1158, category: DiagnosticCategory.Error, key: "Invalid template literal; expected '}'" }, 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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0e06f4fcfb..8d9dbe9409 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -467,10 +467,6 @@ "category": "Error", "code": 1157 }, - "Invalid template literal; expected '}'": { - "category": "Error", - "code": 1158 - }, "Tagged templates are only available when targeting ECMAScript 6 and higher.": { "category": "Error", "code": 1159 diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1f06094574..9bfde417a2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1676,13 +1676,12 @@ module ts { literal = parseLiteralNode(); } else { - error(Diagnostics.Invalid_template_literal_expected); + parseExpected(SyntaxKind.CloseBraceToken); literal = createMissingNode(); literal.text = ""; } span.literal = literal; - return finishNode(span); } diff --git a/tests/baselines/reference/TemplateExpression1.errors.txt b/tests/baselines/reference/TemplateExpression1.errors.txt index bf57f5ef24..c13b0fabd5 100644 --- a/tests/baselines/reference/TemplateExpression1.errors.txt +++ b/tests/baselines/reference/TemplateExpression1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/templates/TemplateExpression1.ts(1,19): error TS1158: Invalid template literal; expected '}' +tests/cases/conformance/es6/templates/TemplateExpression1.ts(1,19): error TS1005: '}' expected. tests/cases/conformance/es6/templates/TemplateExpression1.ts(1,17): error TS2304: Cannot find name 'a'. ==== tests/cases/conformance/es6/templates/TemplateExpression1.ts (2 errors) ==== var v = `foo ${ a -!!! error TS1158: Invalid template literal; expected '}' +!!! error TS1005: '}' expected. ~ !!! error TS2304: Cannot find name 'a'. \ No newline at end of file