Skip to content

Revert "Fix infinite loop"#63617

Closed
liu-idf18 wants to merge 1 commit into
microsoft:mainfrom
liu-idf18:revert-63581-fix-infinite-loop
Closed

Revert "Fix infinite loop"#63617
liu-idf18 wants to merge 1 commit into
microsoft:mainfrom
liu-idf18:revert-63581-fix-infinite-loop

Conversation

@liu-idf18

Copy link
Copy Markdown

Reverts #63581

@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jul 6, 2026
@liu-idf18 liu-idf18 marked this pull request as ready for review July 6, 2026 04:48
Copilot AI review requested due to automatic review settings July 6, 2026 04:48
@typescript-automation

Copy link
Copy Markdown

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts prior changes from #63581 (“Fix infinite loop”). In its current form, the revert reintroduces a scanner loop condition that can spin indefinitely, and it also removes a regression test that would help catch this class of issue.

Changes:

  • Reverts a precedence fix in createScanner’s identifier scanning loop involving CharacterCodes.minus.
  • Removes a unit test covering /** ... -*/ block comment parsing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/compiler/scanner.ts Reverts the while condition grouping in identifier scanning, which reintroduces an infinite-loop risk.
src/testRunner/unittests/comments.ts Removes the regression test that exercised block comments ending in -*/.

Comment thread src/compiler/scanner.ts
if (isIdentifierStart(ch, languageVersion)) {
let char = ch;
while (pos < end && (isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === CharacterCodes.minus)) pos += charSize(char);
while (pos < end && isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === CharacterCodes.minus) pos += charSize(char);
Comment on lines 31 to 32
});

it("parses /** block comments ending in hyphen", () => {
const sourceFile = ts.createSourceFile(
"file.ts",
`${endingInHyphen}\nconst x = 1;`,
ts.ScriptTarget.ESNext,
/*setParentNodes*/ true,
);

assert.strictEqual(sourceFile.parseDiagnostics.length, 0);
assert.strictEqual(sourceFile.statements.length, 1);
});
});
@jakebailey jakebailey closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants