graphify icon indicating copy to clipboard operation
graphify copied to clipboard

[Bug]: Swift: _bar() and bar() share one node id, and cross-file foo._bar() resolves to bar()

Open rohit-jsfreaky opened this issue 2 weeks ago • 2 comments

Pre-flight checks

  • [x] I have checked the Troubleshooting section in the README

What happened?

In Swift, two members whose names differ only by a leading _ (_bar() / bar()), or only by case, get one node id. One of them disappears from the graph, and its calls are credited to the other.

_name is common in Apple's open-source Swift (swift-nio, swift-collections). The cross-file resolver folds names too, so on v8 foo._bar() from another file also lands on bar().

This is the same bug fixed for Solidity in #5058 and Java in #5152; Python and C# already keep such twins apart (#3302, #4415).

The answer key is a separate tree-sitter scan that counts declarations per class/type.

repo groups no node: v8 -> this PR nodes gained calls fixed v8 ids changed
Alamofire 3 3 -> 0 3 15 0
swift-nio 59 59 -> 0 65 147 1 (hexdumpDetailed/hexDumpDetailed)
swift-collections 55 52 -> 0 69 192 0

Steps to reproduce

// Foo.swift
class Foo {
  func bar() { helper() }
  func _bar() { other() }
  func caller() { _bar(); bar() }
}

Run graphify update . and list the nodes and calls edges.

Error output or graph output

v8: no ._bar() node; .bar() calls both helper and other.

Expected: foo_foo_bar_2c4c06 (._bar()) exists and every call lands on the right method.

Graphify version

0.9.108 (v8 at 52cb2821)

Operating System

Windows (also seen on Linux)

Python Version

3.12

Installation Method

uv tool install (recommended)

rohit-jsfreaky avatar Nov 13 '26 17:11 rohit-jsfreaky

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.

github-actions[bot] avatar Nov 13 '26 17:11 github-actions[bot]

Fixed by #5204 (e68e7286), released in graphify 0.9.109. Thanks @rohit-jsfreaky.

safishamsi avatar Nov 14 '26 22:11 safishamsi