Repository navigation
Description
Net-new over v8 (verified @6478eb71, 0.9.80)
v8 has no Go decl/def fold: graphify/extractors/resolution.py has _merge_decl_def_classes
(C/C++/ObjC) but no _merge_go_package_types, and nothing collapses the per-file Go type
fragmentation before _disambiguate_colliding_node_ids salts the colliding ids by path.
The bug reproduces exactly as described below.
Still missing, and what the paired PR adds: _merge_go_package_types, invoked right after
_merge_decl_def_classes and before disambiguation, folding same-id bare-label .go type
nodes in one directory into a single node (declaration site wins; cross-directory
same-named packages and _test.go members excluded). Fully net-new.
Summary
A Go type whose methods live in other files of the same package becomes several nodes, one
per file, each owning only the methods declared there. The declaring file's node owns none of
them. Every downstream single-definition guard then reads the set as an ambiguity and bails, so
an idiomatic multi-file package loses type-level resolution.
C/C++/ObjC hit the same id-collision between a header declaration and its impl and avoid this
through _merge_decl_def_classes (graphify/extractors/resolution.py), which folds the
collision before _disambiguate_colliding_node_ids splits it. Go has no equivalent.
Reproducer
svc/a.go package svc; type Server struct{}; func Run(srv *Server) { srv.Close() }
svc/b.go package svc; func (s *Server) Close() {}
svc/c.go package svc; func (s *Server) Save() {}
$ graphify extract svc/
Actual — three Server nodes, and the methods hang off two of them:
nodes labelled Server:
..._svc_a_go_svc_server | a.go
..._svc_b_go_svc_server | b.go
..._svc_c_go_svc_server | c.go
edges:
a.go -> Server | contains
Run() -> Server | references (parameter_type)
Server -> .Close() | method <- the b.go node
Server -> .Save() | method <- the c.go node
Expected — one Server, sourced at its declaration, owning both methods:
svc_server | a.go
a.go -> Server | contains
Run() -> Server | references (parameter_type)
Server -> .Close() | method
Server -> .Save() | method
Why
extract_go mints the receiver's type node in every file that declares a method on it
(graphify/extractors/go.py, the method_declaration branch), keyed
_make_id(pkg_scope, receiver_type) where pkg_scope is the package directory's name. All those
nodes therefore share one id and differ only in source_file — which is exactly the input
_disambiguate_colliding_node_ids is built to split, so it salts each one with its own path.
Impact
referencesto the type land on whichever fragment the referring file produced, so a type's
incoming uses and its methods are no longer reachable from one node.- The id is salted with a file path, so it is neither the canonical
{pkg}_{type}form nor
stable across machines for the affected types. - Every resolver that requires exactly one declaration of a name (member-call resolution, the
Go type-reference rewire) bails, which is silent under-reporting rather than a visible error.
Splitting one Go type into two files is not an edge case; it is how any package larger than a
single file is written.
Fix
Fold the id-collision before disambiguation, mirroring _merge_decl_def_classes. The nodes
already share an id, so no edge re-pointing is needed — only the redundant duplicates are
dropped and the declaring file's node survives.
Guards against a false merge: all members of the collision must be .go files in one
directory (the id folds in only the directory's name, so a/svc and b/svc collide while
being different packages), and a _test.go member stops the fold, since its package clause may
be the separate external svc_test package declaring a type of the same name — extract_go
does not parse the package clause, so same-directory is not evidence of same package there.
PR follows.
Activity
fix(go): fold a package's type into one node when its methods span fi…
fix(go): fold a package's type into one node when its methods span fi…
fix(go): fold a package's type into one node when its methods span fi…
xiongjianxu commentedon Sep 24, 2026
Self-contained, runnable reproduction (driven only by
graphifyonPYTHONPATH, so the same script runs against pristine v8 and against the PR branch). One repo, one packagesvc: the typeServeris declared ina.gowhile its methods live inb.go/c.go.On pristine v8 (
4c73561):extract_gokeys the type on its package directory, so every file declaring a method mintsServeragain under the same id; disambiguation then splits them by path. The type fragments into three partial nodes, and the node that actually declaresServer(a.go) owns none of its methods — so every single-definition guard downstream reads this as an ambiguity.With PR #3400:
_merge_go_package_typesfolds the fragments before disambiguation: oneServernode (sourced at the declaringa.go) owns both methods, and its id returns to the un-salted canonical form. Because the fold keeps the same id, existing edges need no re-pointing.PR #3400 cherry-picks clean onto the current v8 tip
4c73561(git merge-treereports no conflicts; PR isMERGEABLE/CLEAN).fix(go): fold a package's type into one node when its methods span fi…
fix(go): fold a package's type into one node when its methods span fi…
safishamsi commentedon Oct 13, 2026
Fixed in v0.9.89 (
graphifyy 0.9.89on PyPI) via #3400.