Rust: field_type_hint binds a call by its receiver variable name, ignoring the declared type (`source: &Series` → `Source::key` at 0.85)

Offen
#3,006 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
72/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
c, rust

Rechercherichtung

Start in src/pipeline/pass_parallel.c at try_field_type_hint and read the Rust and Go handling, then reproduce with the supplied 57-file Rust project and compare its parallel and sequential CALLS edges. The fix should prevent receiver variable names from creating high-confidence Rust call edges when the declared type differs; verify the two calls resolve consistently without the incorrect Source::key edge.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

editor/integration parsing/quality
Version

v0.12.1 release binary, Linux (x64). The code path is unchanged on main @ cdfdf264.

What happened, and what did you expect?

On the parallel resolver (more than 50 files), a Rust method call whose receiver the LSP leaves untyped goes through try_field_type_hint (src/pipeline/pass_parallel.c). The hint capitalises the receiver's variable name and binds the candidate whose owning segment equals it, at 0.85. #1936 (for #1927) narrowed that from a substring to an owning-segment match, and Go is excluded (F-G9), but Rust still runs it. Segment equality still fires whenever a variable is named after an unrelated project type. The receiver's declared type is never read.

Expected: a variable name alone yields no CALLS edge, least of all at 0.85. source: &Series calls Series::key; source: extcrate::Bar calls the crate's Bar::key.

Reproduction

Cargo.toml ([dependencies] extcrate = "1", never built), src/lib.rs declaring the modules below, plus 55 one-line src/padN.rs files (pub fn padN() -> u32 { N }) to cross MIN_FILES_FOR_PARALLEL.

// src/series.rs
pub enum Series {
    Bars(u32),
}

impl Series {
    pub fn key(&self) -> u32 {
        match self {
            Self::Bars(n) => *n,
        }
    }
}
// src/source.rs
pub struct Source(pub u32);

impl Source {
    pub fn key(&self) -> u32 {
        self.0
    }
}
// src/user.rs
use crate::series::Series;
use extcrate::Bar;

/// Declared `&Series`: calls Series::key. Must not bind Source::key.
pub fn declared_project_type(source: &Series) -> u32 {
    source.key()
}

/// Declared external `Bar`: calls extcrate's Bar::key. Must not bind Source::key.
pub fn declared_external_type(source: Bar) -> u32 {
    source.key()
}
codebase-memory-mcp cli index_repository '{"repo_path":"<repro>"}'
codebase-memory-mcp cli query_graph '{"project":"<p>","query":"MATCH (a)-[r:CALLS]->(b) WHERE b.name = \"key\" RETURN a.name, b.qualified_name, r.strategy, r.confidence"}'
caller parallel (57 files) sequential (same repo without the pad files)
declared_project_type src.source.Source.key, field_type_hint, 0.85 src.series.Series.key, suffix_match, 0.55
declared_external_type src.source.Source.key, field_type_hint, 0.85 src.series.Series.key, suffix_match, 0.55

Both parallel edges are wrong, and the hint turns a 0.55 guess into a 0.85 one. The two resolvers also diverge, which is what F-G9 removed for Go.

Two side notes. Neither edge is lsp_* in either resolver: the LSP leaves source: &Series untyped although Series comes in through use crate::series::Series. The sequential edge for declared_external_type is the external-receiver fallback, which I'm filing separately.

Possible fix: exclude Rust from try_field_type_hint as Go is.

Vorherrschende Sprache
C
Sterne
45.8k
Forks
3.8k
Ø Merge
2 T. 18 Std.
Gemergte PRs (30 T.)
108

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus DeusData/codebase-memory-mcp

Alle Issues in DeusData/codebase-memory-mcp

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.