Repository navigation
Emit "Are you missing a semicolon?" for ASI across U+2028/U+2029 - #65439
Closed
Amal Saidov (amalsaidov) wants to merge 1 commit into
Closed
Amal Saidov (amalsaidov) wants to merge 1 commit into
Amal Saidov (amalsaidov) wants to merge 1 commit into
Conversation
The accidental-call recovery in resolveCallExpression detected the preceding line break by reading a single byte (`rune(text[end-1])`). For the multi-byte line terminators U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR) this reads only the last UTF-8 continuation byte (0xA8 / 0xA9), which is not a line break, so the "Are you missing a semicolon?" related diagnostic was dropped. This worked in the previous (UTF-16) compiler, where those separators are a single code unit. Decode the last rune of the skipped text instead, so all ECMAScript line terminators are recognized. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The hint is still omitted when U+2028 or U+2029 is followed by indentation because SkipTriviaEx honors StopAfterLineBreak only for CR/LF.
1 open issue
What changed in this PR
Addresses #65433 by restoring the “Are you missing a semicolon?” diagnostic for accidental calls split by U+2028 or U+2029 in the native TypeScript compiler.
Changes:
- Decodes the final UTF-8 rune instead of inspecting a single byte.
- Adds regression cases for both Unicode separators and their expected baselines.
| File | Description |
|---|---|
tsc/internal/checker/checker.go |
Uses UTF-8 decoding to recognize multibyte line terminators. |
tsc/testdata/tests/cases/compiler/accidentalCallWithLineSeparator.ts |
Adds accidental-call cases for U+2028 and U+2029. |
tsc/testdata/baselines/reference/compiler/accidentalCallWithLineSeparator.types |
Records expected type information. |
tsc/testdata/baselines/reference/compiler/accidentalCallWithLineSeparator.symbols |
Records expected symbol information. |
tsc/testdata/baselines/reference/compiler/accidentalCallWithLineSeparator.js |
Records expected JavaScript output. |
tsc/testdata/baselines/reference/compiler/accidentalCallWithLineSeparator.errors.txt |
Records call errors with related semicolon hints. |
Review effort: Balanced
Comment on lines
+8781
to
+8782
| lastChar, _ := utf8.DecodeLastRuneInString(text[:end]) | ||
| if stringutil.IsLineBreak(lastChar) { |
Author
|
Thanks for taking a look 🙏 |
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 an accidental call is split by a line terminator (the classic ASI footgun), the checker attaches a related
Are you missing a semicolon?diagnostic. This was dropped when the newline was a nonstandard line terminator — U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR):Only
TS2349: This expression is not callablewas reported, without the semicolon hint. This regressed between the previous (UTF-16) compiler and the native port.Cause
In
resolveCallExpression(tsc/internal/checker/checker.go), the preceding line break was detected withrune(text[end-1])— a single byte. In the native compilertextis a UTF-8string, so for U+2028/U+2029 this reads only the last continuation byte (0xA8/0xA9), whichIsLineBreakdoes not recognize. In the old compiler, strings were UTF-16 and these separators were a single code unit, socharCodeAtworked.Fix
Decode the last rune of the skipped text with
utf8.DecodeLastRuneInStringinstead of indexing a byte, so every ECMAScript line terminator (LF, CR, U+2028, U+2029) is recognized. Behavior for single-byte terminators is unchanged.Tests
tsc/testdata/tests/cases/compiler/accidentalCallWithLineSeparator.tscovering both U+2028 and U+2029; the baseline now includes therelated TS2734: Are you missing a semicolon?sub-error.go -C tsc test -run='TestLocal/accidentalCallWithLineSeparator' ./internal/testrunnerpasses.TestLocalcompiler suite (./internal/testrunner) passes with no baseline drift; existingbetterErrorForAccidentalCallunaffected.AI assistance disclosure
This patch was authored with the assistance of an AI coding tool (Claude Code). I have read and understand the change and will shepherd it through review.
🤖 Generated with Claude Code