Repository navigation
Fix mistaken slice delete in extractFromSymbol - #65480
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
An ignored symbol does not establish that it exists in the resolved export slice. Only remove named entries when their index is valid; createExport already excludes prototype symbols from remaining exports.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The behavior-changing case where idx == -1 and shouldIgnoreSymbol(namedExport) is true lacks a regression test verifying that extraction completes and retains the expected exports.
1 open issue
What changed in this PR
This PR fixes a potential out-of-bounds panic in the language server’s auto-import symbol extraction.
Changes:
- Deletes a named export from the slice only when its index is valid.
- Removes
shouldIgnoreSymbolfrom the deletion guard so it cannot trigger deletion at index-1.
| File | Description |
|---|---|
tsc/internal/ls/autoimport/extract.go |
Guards slice deletion with a successful index lookup. |
Review effort: Balanced
| if name != ast.InternalSymbolNameExportStar { | ||
| idx := slices.Index(allExports, namedExport) | ||
| if idx >= 0 || shouldIgnoreSymbol(namedExport) { | ||
| if idx >= 0 { |
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.

I haven't found a test case, but this would crash if the second condition were true because the index is out of bounds.