diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 4b4d3f3d723..b109ba8bfbd 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -662,11 +662,14 @@ module ts { if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) { pos += 2; - while (pos < len) { + var safeLength = len - 1; // For lookahead. + var commentClosed = false; + while (pos < safeLength) { var ch = text.charCodeAt(pos); if (ch === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) { pos += 2; + commentClosed = true; break; } @@ -676,6 +679,11 @@ module ts { pos++; } + if (!commentClosed) { + pos++; + onError(Diagnostics.Asterisk_Slash_expected); + } + if (onComment) { onComment(tokenPos, pos); } diff --git a/tests/baselines/reference/parserKeywordsAsIdentifierName2.errors.txt b/tests/baselines/reference/parserKeywordsAsIdentifierName2.errors.txt new file mode 100644 index 00000000000..41b5ab32f89 --- /dev/null +++ b/tests/baselines/reference/parserKeywordsAsIdentifierName2.errors.txt @@ -0,0 +1,7 @@ +==== tests/cases/conformance/parser/ecmascript5/parserKeywordsAsIdentifierName2.ts (2 errors) ==== + // 'public' should be marked unusable, should complain on trailing /* + a.public /* + +!!! '*/' expected. + ~ +!!! Cannot find name 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/parserKeywordsAsIdentifierName2.js b/tests/baselines/reference/parserKeywordsAsIdentifierName2.js deleted file mode 100644 index 8038ddd5f37..00000000000 --- a/tests/baselines/reference/parserKeywordsAsIdentifierName2.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [parserKeywordsAsIdentifierName2.ts] -// 'public' shoudl be marked unusable because it has a trailing /* -//a.public /* - -//// [parserKeywordsAsIdentifierName2.js] diff --git a/tests/baselines/reference/scannerS7.4_A2_T2.errors.txt b/tests/baselines/reference/scannerS7.4_A2_T2.errors.txt new file mode 100644 index 00000000000..4d3d2500e08 --- /dev/null +++ b/tests/baselines/reference/scannerS7.4_A2_T2.errors.txt @@ -0,0 +1,17 @@ +==== tests/cases/conformance/scanner/ecmascript5/scannerS7.4_A2_T2.ts (1 errors) ==== + // Copyright 2009 the Sputnik authors. All rights reserved. + // This code is governed by the BSD license found in the LICENSE file. + + /** + * Correct interpretation of multi line comments + * + * @path ch07/7.4/S7.4_A2_T2.js + * @description Try use /*CHECK#1/. This is not closed multi line comment + * @negative + */ + + /*CHECK#1/ + + + +!!! '*/' expected. \ No newline at end of file diff --git a/tests/baselines/reference/scannerS7.4_A2_T2.js b/tests/baselines/reference/scannerS7.4_A2_T2.js deleted file mode 100644 index ae5acbaece4..00000000000 --- a/tests/baselines/reference/scannerS7.4_A2_T2.js +++ /dev/null @@ -1,17 +0,0 @@ -//// [scannerS7.4_A2_T2.ts] -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/** - * Correct interpretation of multi line comments - * - * @path ch07/7.4/S7.4_A2_T2.js - * @description Try use /*CHECK#1/. This is not closed multi line comment - * @negative - */ - -/*CHECK#1/ - - - -//// [scannerS7.4_A2_T2.js] diff --git a/tests/cases/conformance/parser/ecmascript5/parserKeywordsAsIdentifierName2.ts b/tests/cases/conformance/parser/ecmascript5/parserKeywordsAsIdentifierName2.ts index cac3a668cbf..d197f85905c 100644 --- a/tests/cases/conformance/parser/ecmascript5/parserKeywordsAsIdentifierName2.ts +++ b/tests/cases/conformance/parser/ecmascript5/parserKeywordsAsIdentifierName2.ts @@ -1,2 +1,2 @@ -// 'public' shoudl be marked unusable because it has a trailing /* -//a.public /* \ No newline at end of file +// 'public' should be marked unusable, should complain on trailing /* +a.public /* \ No newline at end of file