Skip to content

Fix ASI diagnostics for Unicode line separators (U+2028 and U+2029) - #65461

Open
amr sarhan (amr807) wants to merge 3 commits into
microsoft:mainfrom
amr807:fix/asi-unicode-line-separators
Open

amr sarhan (amr807) wants to merge 3 commits into
microsoft:mainfrom
amr807:fix/asi-unicode-line-separators

Conversation

@amr807

Copy link
Copy Markdown

Summary

Fix incorrect and missing automatic semicolon insertion (ASI) diagnostics when source code contains the Unicode line separators U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR).

These characters are valid ECMAScript line terminators. However, parts of the Go implementation were checking source text one byte at a time. Since both characters occupy three bytes in UTF-8, these checks could incorrectly detect line breaks and calculate source positions.

Changes

  • Recognize U+2028 and U+2029 as line terminators in scanner trivia handling.
  • Use UTF-8 rune decoding when detecting line breaks in the checker.
  • Correct UTF-8-aware source-position calculations in language-service change tracking.
  • Add compiler regression cases covering both Unicode line separators.
  • Add scanner tests for Unicode line separators, including StopAfterLineBreak behavior and existing LF/CRLF behavior.
  • Add language-service regression tests verifying insertion positions around Unicode line separators.

Testing

  • go -C ./tsc test -count=1 ./...
  • Scanner regression tests.
  • Language-service change-tracking regression tests.
  • Compiler regression test for betterErrorForAccidentalCall.

Related issue

Fixes #65433.

AI assistance disclosure

I used OpenAI ChatGPT (GPT-6) as an AI coding assistant during bug investigation, implementation, code review, and test development. I personally reviewed the changes, verified the implementation, ran the tests, and understand the submitted code. I will personally maintain this pull request and respond to review feedback.

Copilot AI balanced review requested due to automatic review settings November 13, 2026 01:36
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 13, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Nov 13, 2026

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@amr807
amr sarhan (amr807) requested a balanced review from Copilot November 13, 2026 01:39

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@amr807

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@amr807
amr sarhan (amr807) requested a balanced review from Copilot November 13, 2026 01:43

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@amr807
amr sarhan (amr807) requested a balanced review from Copilot November 13, 2026 01:44

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Incorrect error message when ASI errors involve a nonstandard newline

2 participants