Skip to content

Report errors on unclosed multiline comments. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -676,6 +679,11 @@ module ts {
pos++;
}

if (!commentClosed) {
pos++;
onError(Diagnostics.Asterisk_Slash_expected);
}

if (onComment) {
onComment(tokenPos, pos);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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'.
5 changes: 0 additions & 5 deletions tests/baselines/reference/parserKeywordsAsIdentifierName2.js

This file was deleted.

17 changes: 17 additions & 0 deletions tests/baselines/reference/scannerS7.4_A2_T2.errors.txt
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 0 additions & 17 deletions tests/baselines/reference/scannerS7.4_A2_T2.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 'public' shoudl be marked unusable because it has a trailing /*
//a.public /*
// 'public' should be marked unusable, should complain on trailing /*
a.public /*