Skip to content

fix: renamed imports track alias instead of original name #3

@TonyStef

Description

@TonyStef

Problem

import { foo as bar } from './utils' stores bar in symbols_referenced, but the actual symbol in ./utils is foo. When someone deletes foo, the stored reference bar doesn't match — missed detection.

Location: collectImportNames() in src/parser/ast.ts, line 255:

const localName = (spec.childForFieldName('alias') ?? spec.childForFieldName('name'))?.text;

This prefers the alias over the original name.

Fix

Use spec.childForFieldName('name') (the original export name) instead of preferring alias. One-line change.

Severity

Causes silent missed detections for any codebase that renames imports.

Reproduction

  1. PR A adds export function foo() in utils.ts
  2. PR B adds import { foo as bar } from './utils' — stores reference as bar
  3. PR C deletes foo from utils.ts — deleted symbol is foo
  4. symbolMatches compares bar vs foo → no match → regression missed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions