Repository navigation
fix(go): fold sibling-file type copies per directory when a same-named package exists - #5414
PravalVerma wants to merge 1 commit into
Conversation
…d package exists When two package directories share a name (alpha/ and other/alpha/) and both declare the same type, _merge_go_package_types skipped the whole id group, so a type declared in one file with methods in a sibling file stayed fragmented. The package-scoped receiver lookup then saw two candidates and dropped the same-file s.helper() call. 0.9.101 emitted it; 0.9.112+ did not. Fold each directory's copies separately. The survivor records the files it absorbed in a transient _go_folded_files, which _disambiguate_colliding_node_ids consumes so those files' method edges follow the salted survivor instead of staying on the dead bare id. Follow-up to Graphify-Labs#5304.
|
Thanks for the pull request, @PravalVerma. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify review 
4 possible issues to check · High impact
Go type copies now fold within each source directory, even when another directory has the same package name.
4 possible issues we couldn't confirm
- The leak check for
_go_folded_filesonly scans node entries, so the key could appear on edges or the result without failing ·tests/test_go_sibling_receiver_with_outside_reference.py:142 - Path helper
_relraises a ValueError for absolute paths outside the test root, hiding the real assertion ·tests/test_go_sibling_receiver_with_outside_reference.py:96 - The
Servicecount compares raw labels, while the other helpers strip punctuation before matching ·tests/test_go_sibling_receiver_with_outside_reference.py:128 - +1 more in Graphify
They don't change the score.
Code graph · 4391 functions depend on this change
- 48 of 613 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed 9f5d250 · Full report in the Graphify check
Bump _AST_CACHE_SCHEMA 54 -> 55 for the Python function-parameter call change (#5418), so cached Python extractions re-run; its walk_calls guard was combined with the 0.9.119 lambda-parameter guard (both suppress a bare Python call under a shadowing binding). Harden the #5414 go-fold test with a node-count assert so it fails without the fix. The wiki/affected/build changes need no schema bump. 0.9.120 changelog and version bump. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in v0.9.119 via an authorship-preserving cherry-pick. A type declared across sibling files folds per directory even when a same-named package exists elsewhere, so its member calls resolve while the two packages stay distinct. One maintainer tweak: hardened one of the new tests with a node-count assert so it fails without the fix. Thanks @PravalVerma! |
Follow-up to #5304.
dd11a045(shipped in 0.9.113) fixed the shape reported in #5304. One closely related shape still drops the call: the receiver type is declared in a sibling file, and another package directory with the same name (alpha/andother/alpha/, the #5242 layout) also declares that type. No outside reference is needed.Repro
callsedge forRun → helper:['calls']v8)[]['calls']Cause
_merge_go_package_typesskipped any id group that spanned more than one directory. Soalpha/impl.gokept its own copy ofService, holding both methods. After disambiguation, the package-scoped lookup in_resolve_go_member_callsfound twoServicenodes inexample.com/app/alphaand gave up.Fix
_merge_go_package_typesnow folds each directory's copies on its own. Same-named directories still stay split from each other, astest_two_packages_sharing_a_directory_name_stay_splitrequires._disambiguate_colliding_node_idssalts it by path. The folded files'methodedges are keyed by their own path, which is in no salt (the [Bug]: Go: s.method() edge dropped when the receiver type is in a sibling file and another package names the type (0.9.112) #5304 mechanism). The survivor therefore records the files it absorbed in a transient_go_folded_files. The disambiguation pass consumes it, always pops it, and re-points those edges to the salted survivor.impl.gofragment disappears. No AST cache bump is needed, because the change is assembly-time only.Tests
test_go_sibling_receiver_with_outside_reference.py: same-named package, with and without an outside reference. It asserts the call, that each package keeps oneServiceowning its own methods, and that_go_folded_filesnever reaches the output. A second test covers both packages using the sibling layout.test_go_package_type_fold.py: each of two same-named packages still folds its own files.v8and pass with this change.v8(test_ext_tagged_id_clash,test_pascal_singleton_resolution, two*_memoizationtests, onetest_multilang), so they are unrelated.resolution.pyis unchanged.