Skip to content

fix(65433): restore ASI semicolon hint for U+2028/U+2029 - #65715

Closed
Sumit G (smg99) wants to merge 2 commits into
microsoft:mainfrom
smg99:fix/65433-asi-line-separator
Closed

Sumit G (smg99) wants to merge 2 commits into
microsoft:mainfrom
smg99:fix/65433-asi-line-separator

Conversation

@smg99

@smg99 Sumit G (smg99) commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #65433

Problem

When a non-callable expression is followed by (args) across an ECMAScript line terminator, TypeScript adds related diagnostic TS2734 ("Are you missing a semicolon?"). That hint worked for LF/CR but not for U+2028 (line separator) / U+2029 (paragraph separator), e.g.:

const a = (x: number) => x\u2028(1)

Cause

Two Go-port issues:

  1. SkipTriviaEx with StopAfterLineBreak only stopped for \n/\r. U+2028/U+2029 were treated as generic Unicode whitespace and skipped past.
  2. The checker tested rune(text[pos-1]) after trivia. That is a UTF-8 byte index, so for the 3-byte encodings of LS/PS it never saw a line break.

Fix

  • Stop after U+2028/U+2029 in SkipTriviaEx when StopAfterLineBreak is set.
  • Use utf8.DecodeLastRuneInString when checking the character before the call args.

Tests

  • Compiler case betterErrorForAccidentalCallLineSeparator.ts (issue repro with U+2028) + baselines showing related TS2734.
  • Unit test TestSkipTriviaStopsAfterUnicodeLineBreaks covers LF, CR, CRLF, U+2028, and U+2029.

Notes

  • A U+2029 compiler baseline was not added: the error-baseline harness panics when formatting that case (slice bounds out of range). Scanner unit coverage still includes U+2029.
  • Pre-existing: ls/change/delete.go and ls/change/trackerimpl.go still use text[pos-1] after SkipTriviaEx(..., StopAfterLineBreak). With this scanner fix those paths can now run for LS/PS, but the byte index remains incorrect for multi-byte terminators. Impact is limited to language-service edits on rare LS/PS source; suitable follow-up, not required for the diagnostic fix.

Checklist

  • There is an associated issue in the Backlog milestone (required)
  • Code is up-to-date with the main branch
  • You've successfully run npx hereby test (focused Go/compiler coverage for this change)
  • You've successfully run npx hereby lint
  • You've successfully run npx hereby check:format
  • There are new or updated tests validating the change

Stop SkipTrivia after Unicode line terminators when requested, and
decode the previous UTF-8 rune when checking for a line break so the
"Are you missing a semicolon?" related diagnostic fires for LS/PS ASI.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 05:19
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 28, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Nov 28, 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 regression tests also pass with the original scanner, so they need whitespace after U+2028/U+2029 and position assertions immediately after each terminator to catch a reverted scanner fix.

1 open issue
What changed in this PR

Restores the “Are you missing a semicolon?” diagnostic hint for accidental calls separated by U+2028 or U+2029, addressing the Go-port regression in #65433.

Changes:

  • Makes trivia scanning stop after Unicode line terminators when requested.
  • Decodes the preceding UTF-8 rune when deciding whether to attach the hint.
  • Adds scanner tests and a U+2028 compiler regression case with diagnostic, emit, type, and symbol baselines.
File Description
tsc/​testdata/​tests/​cases/​compiler/​betterErrorForAccidentalCallLineSeparator.ts Adds U+2028 accidental-call cases.
tsc/​testdata/​baselines/​reference/​compiler/​betterErrorForAccidentalCallLineSeparator.types Records inferred types.
tsc/​testdata/​baselines/​reference/​compiler/​betterErrorForAccidentalCallLineSeparator.symbols Records symbol bindings.
tsc/​testdata/​baselines/​reference/​compiler/​betterErrorForAccidentalCallLineSeparator.js Records emitted JavaScript.
tsc/​testdata/​baselines/​reference/​compiler/​betterErrorForAccidentalCallLineSeparator.errors.txt Records invocation errors and TS2734 hints.
tsc/​internal/​scanner/​scanner.go Stops trivia scanning after Unicode line terminators.
tsc/​internal/​scanner/​scanner_test.go Tests scanner offsets across five newline forms.
tsc/​internal/​checker/​checker.go Uses UTF-8 decoding for the semicolon-hint check.

Review effort: Balanced

Comment thread tsc/internal/scanner/scanner_test.go Resolved
Put space after each line terminator in the ASI regression fixtures so
a reverted scanner StopAfterLineBreak change fails the unit and
compiler tests instead of coincidentally matching '(' offsets.

Co-authored-by: Cursor <cursoragent@cursor.com>
@smg99

Copy link
Copy Markdown
Contributor Author

Closing after re-reading the contribution guidelines regarding issue #65433. Sorry for the noise.

@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Nov 29, 2026
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: Done

Development

Successfully merging this pull request may close these issues.

Incorrect error message when ASI errors involve a nonstandard newline

2 participants