Skip to content

Prevent infinite loop in unstable AST JSDoc scanner - #64141

Merged
Jake Bailey (jakebailey) merged 3 commits into
mainfrom
copilot/fix-scanjsdoctoken-infinite-loop
Sep 4, 2026
Merged

Prevent infinite loop in unstable AST JSDoc scanner#64141
Jake Bailey (jakebailey) merged 3 commits into
mainfrom
copilot/fix-scanjsdoctoken-infinite-loop

Conversation

Copilot AI commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

The unstable AST JSDoc scanner could loop indefinitely when a scan range ended immediately after -, because the range check did not guard the full identifier condition.

Changes

  • Guard both identifier parts and hyphens with pos < end:
while (pos < end && (isIdentifierPart(...) || char === CharacterCodes.minus))
  • Add regression coverage verifying that a range ending in x- reaches EOF and preserves the expected tokens.

Copilot AI and others added 2 commits September 3, 2026 01:00
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix infinite loop in scanJsDocToken for unstable/ast Prevent infinite loop in unstable AST JSDoc scanner Sep 3, 2026
@jakebailey
Jake Bailey (jakebailey) marked this pull request as ready for review September 3, 2026 04:37
Copilot AI balanced review requested due to automatic review settings September 3, 2026 04:37

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.

🟢 Approval recommended

The focused fix correctly addresses the precedence bug and includes matching regression coverage.

Pull request overview

Fixes an infinite loop in the unstable AST JSDoc scanner when a scan range ends with a hyphen.

Changes:

  • Correctly bounds hyphenated identifier scanning.
  • Adds regression coverage for EOF and token preservation.
File summaries
File Description
packages/typescript/src/ast/scanner.ts Fixes the scanner range condition.
packages/typescript/test/scanner.test.ts Tests trailing-hyphen range scanning.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 31e0087 Sep 4, 2026
27 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the copilot/fix-scanjsdoctoken-infinite-loop branch September 4, 2026 21:44
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.

unstable/ast: scanJsDocToken infinite-loops when a scan range ends on a trailing '-' (fix from #63581 not carried into the AST scanner)

4 participants