Skip to content

fix: detect Unicode line separators in ASI diagnostics - #65454

Open
Falak Ahuja (falakahuja) wants to merge 2 commits into
microsoft:mainfrom
falakahuja:fix/asi-nonstandard-newline-diagnostic
Open

Falak Ahuja (falakahuja) wants to merge 2 commits into
microsoft:mainfrom
falakahuja:fix/asi-nonstandard-newline-diagnostic

Conversation

@falakahuja

Copy link
Copy Markdown

Fixes #65433

The accidental-call diagnostic checks the character immediately before the call after skipping trivia. The checker source is UTF-8, so indexing the final byte misses multi-byte line separators such as U+2028 and U+2029. Decode the final rune before checking whether it is a line break.

Adds a compiler regression case for U+2028 and the generated error, JavaScript output, type, and symbol baselines.

Validation:

  • go -C ./tsc test -run='TestLocal/issue65433NonstandardNewlineASI' ./internal/testrunner — passed.
  • go -C ./tsc test ./internal/checker — passed.
  • go -C ./tsc build ./cmd/tsc — passed.
  • gofmt -d tsc/internal/checker/checker.go — clean.
  • The full go test ./... run was started but not completed.

AI assistance was used to author this change.

Copilot AI balanced review requested due to automatic review settings November 12, 2026 15:01
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 12, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Nov 12, 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.

🟡 Changes recommended

The semicolon hint remains missing when U+2028 or U+2029 is followed by indentation because trivia scanning does not stop at these Unicode line terminators.

1 open issue
What changed in this PR

Addresses #65433 by decoding UTF-8 before checking for a line break, restoring the “Are you missing a semicolon?” hint for Unicode-separated accidental calls.

Changes:

  • Replaces byte indexing with final-rune decoding in the checker.
  • Adds a U+2028 compiler regression case and diagnostic, JavaScript, type, and symbol baselines.
File Description
tsc/​internal/​checker/​checker.go Decodes the final rune before classifying a line break.
tsc/​testdata/​tests/​cases/​compiler/​issue65433NonstandardNewlineASI.ts Adds the U+2028 accidental-call regression case.
tsc/​testdata/​baselines/​reference/​compiler/​issue65433NonstandardNewlineASI.errors.txt Records the expected semicolon hint.
tsc/​testdata/​baselines/​reference/​compiler/​issue65433NonstandardNewlineASI.js Records emitted JavaScript.
tsc/​testdata/​baselines/​reference/​compiler/​issue65433NonstandardNewlineASI.types Records inferred types.
tsc/​testdata/​baselines/​reference/​compiler/​issue65433NonstandardNewlineASI.symbols Records symbol bindings.

Review effort: Balanced

options := scanner.SkipTriviaOptions{StopAfterLineBreak: true}
if stringutil.IsLineBreak(rune(text[scanner.SkipTriviaEx(text, node.Expression().End(), &options)-1])) {
relatedInformation = createDiagnosticForNode(node.Expression(), diagnostics.Are_you_missing_a_semicolon)
end := scanner.SkipTriviaEx(text, node.Expression().End(), &options)
@falakahuja

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

Sponsor
SponsoredKunjungi sekarang
Promo