Repository navigation
fix: detect Unicode line separators in ASI diagnostics - #65454
Open
Falak Ahuja (falakahuja) wants to merge 2 commits into
Open
Falak Ahuja (falakahuja) wants to merge 2 commits into
Falak Ahuja (falakahuja) wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 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) |
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
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
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.go test ./...run was started but not completed.AI assistance was used to author this change.