Skip to content

[Bug]: Rust: an in-file call binds to any same-named function, so Matcher::new() reaches Printer::new() and Arc::new(x) reaches the file's own new #4237

Closed

Description

@rohit-jsfreaky

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

extract_rust binds a call inside one file by the callee's bare name alone (label_to_nid.get(callee_name) in walk_calls, graphify/extractors/rust.py). The index holds every node in the file, last one wins, and the call's shape is ignored:

  • Matcher::new() goes to whichever fn new the file defines last, even impl Printer's.
  • Arc::new(x), Vec::default(), String::from(..) (std types) go to the file's own new / default / from.
  • self.go() goes to another type's go when both types live in the file.
  • drop(x) (a free call) goes to impl Drop's method; x.total() (a method call) goes to a free fn total.

All these edges are calls, EXTRACTED, confidence 1.0.

Measured against rust-analyzer (go-to-definition at every call inside every fn), 0.9.80, calls edges whose both ends are in .rs files:

repo calls edges correct wrong: another fn in the repo wrong: real target is std or a dependency
ripgrep 3129 1852 970 262 (39.4% wrong)
bat 774 602 98 40 (17.8% wrong)
fd 181 148 9 20 (16.0% wrong)

Steps to reproduce

mkdir -p demo/src && cd demo
cat > src/lib.rs <<'EOF'
use std::sync::Arc;

pub struct Matcher;
pub struct Printer;

impl Matcher {
    pub fn new() -> Matcher { Matcher }
}

impl Printer {
    pub fn new() -> Printer { Printer }
}

pub fn make_matcher() -> Matcher { Matcher::new() }
pub fn share(m: Matcher) -> Arc<Matcher> { Arc::new(m) }
EOF
graphify update . --no-cluster
python -c "import json; g=json.load(open('graphify-out/graph.json')); n={x['id']:(x['label'],x.get('source_location')) for x in g['nodes']}; [print(n[e['source']], '->', n[e['target']]) for e in g.get('links', g.get('edges', [])) if e['relation']=='calls']"

Error output or graph output

('make_matcher()', 'L14') -> ('.new()', 'L11')   # wrong: Printer::new, the call is Matcher::new (L7)
('share()', 'L15') -> ('.new()', 'L11')          # wrong: std's Arc::new, not Printer::new

Expected: ('make_matcher()', 'L14') -> ('.new()', 'L7') and no edge from share().

Graphify version

0.9.80 (6478eb7)

Operating System

Windows

Python Version

3.12

Installation Method

built from source (git clone)

Additional Environment Details

No LLM keys; AST only. Clean checkout of v8 @ 6478eb7 reproduces.

Additional context

The call already says which type it means (Matcher::, Self::, self. inside impl Matcher), and the extractor knows each method's impl type, so the in-file match can be restricted to that type's methods. Related but different: #2313 (the shared builtin-name list), #2774 (node ids merged by bare name), #2135 (lowercase module::f() across files). PR right after this issue.

Activity

  1. added
    bug
    on Oct 8, 2026
  2. github-actions commented on Oct 8, 2026

    @github-actions

    Thanks for opening this issue, @rohit-jsfreaky. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  3. safishamsi commented on Oct 9, 2026

    @safishamsi
    Member

    Fixed by #4238 (thanks @rohit-jsfreaky), shipped in v0.9.82. Closing as resolved.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions