Skip to content

Fix mistaken slice delete in extractFromSymbol - #65480

Open
Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:compiler-fixes/autoimport-export-star
Open

Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:compiler-fixes/autoimport-export-star

Conversation

@jakebailey

Copy link
Copy Markdown
Member

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

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.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 05:19
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 13, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 13, 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 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 shouldIgnoreSymbol from 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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

2 participants