Repository navigation
fix(65433): restore ASI semicolon hint for U+2028/U+2029 - #65715
Closed
Sumit G (smg99) wants to merge 2 commits into
Closed
Sumit G (smg99) wants to merge 2 commits into
Sumit G (smg99) wants to merge 2 commits into
Conversation
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>
Contributor
There was a problem hiding this comment.
🟡 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
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>
Contributor
Author
|
Closing after re-reading the contribution guidelines regarding issue #65433. Sorry for the noise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.:Cause
Two Go-port issues:
SkipTriviaExwithStopAfterLineBreakonly stopped for\n/\r. U+2028/U+2029 were treated as generic Unicode whitespace and skipped past.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
SkipTriviaExwhenStopAfterLineBreakis set.utf8.DecodeLastRuneInStringwhen checking the character before the call args.Tests
betterErrorForAccidentalCallLineSeparator.ts(issue repro with U+2028) + baselines showing related TS2734.TestSkipTriviaStopsAfterUnicodeLineBreakscovers LF, CR, CRLF, U+2028, and U+2029.Notes
slice bounds out of range). Scanner unit coverage still includes U+2029.ls/change/delete.goandls/change/trackerimpl.gostill usetext[pos-1]afterSkipTriviaEx(..., 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
Backlogmilestone (required)mainbranchnpx hereby test(focused Go/compiler coverage for this change)npx hereby lintnpx hereby check:format