fix(cpp): distinct nodes for union- and anonymous-namespace-nested same-tail types (#1995)#1998
Closed
magyargergo wants to merge 3 commits into
Closed
Conversation
…d-qualified Impl node (abhigyanpatwari#1992) A generic inherent-impl target (`impl<T> Inner<T>`) is a `generic_type` node, which the inherent-impl owner walk (findEnclosingClassInfo) did not match — so the walk returned null and the method got `File -> DEFINES` with NO HAS_METHOD edge (orphaned, and invisible to findDanglingEdges). The Impl node was already correctly mod-qualified (the @name capture drills into the inner type_identifier, tree-sitter-queries.ts), so this is an owner-walk-only fix: drill into the generic base and mirror the node gate so the owner id == the node id byte-for-byte. A scoped-generic target (`impl<T> a::Inner<T>`) materializes no Impl node and is left orphaned (deferred) rather than minting a phantom owner. The owner walk is shared by the sequential and worker paths. New fixture + tests assert positive HAS_METHOD ownership through distinct `a.Inner` / `b.Inner` nodes on both resolver legs and the worker path, plus a negative scoped-generic guard. rust-captures-golden regenerated additively for the new fixture. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@magyargergo is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
CI Report❌ Some checks failed Pipeline Status
Test Results
✅ All 11052 tests passed 16 test(s) skipped — expand for details
Code CoverageTests
📋 View full run · Generated by CI |
…bhigyanpatwari#1995) `union_specifier` was missing from cppClassConfig.ancestorScopeNodeTypes, so a struct nested in `union U1` and one in `union U2` both qualified to the bare `Inner` and merged onto one Struct:...:Inner node — from_u1/from_u2 cross-wired (invisible to findDanglingEdges). Adding `union_specifier` lets buildQualifiedName pick up the named union's `name` segment, materializing distinct `U1.Inner` / `U2.Inner` nodes. Anonymous unions have no `name` child and correctly contribute nothing (members inject into the enclosing scope); the separate C config is untouched. New fixture + positive-identity tests (sequential + worker, both legs). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…es (abhigyanpatwari#1995) An anonymous `namespace { }` is a namespace_definition with no `name` child, so the scope walker dropped it (empty segment) and two `namespace { struct Inner {} }` blocks in one TU collapsed onto a single `Inner` node — from_anon_a/from_anon_b cross-wired. A C++ `extractScopeSegments` override (the first consumer of the existing config hook) gives each anonymous namespace a deterministic per-block discriminator from its start byte, keeping the nested types distinct. Named scopes (incl. `inline namespace`) and anonymous unions are unaffected. Deterministic across the sequential and worker full-file parses. New fixture + tests assert node DISTINCTNESS (count==2 / distinct owners), not the non-portable discriminator value. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dd91c44 to
059e562
Compare
Collaborator
Author
|
Superseded by same-repo stacked PR #2004. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #1981 (#1978). PR #1981 made namespace/class/struct-nested same-tail C++ types distinct via
qualifiedNodeId. Two scope kinds were left out and still merged: types nested in sibling named unions and in anonymous namespaces. This ships both as two commits.Named unions (commit 1)
union_specifierwas missing fromcppClassConfig.ancestorScopeNodeTypes, so a struct inunion U1and one inunion U2both qualified to the bareInnerand merged onto oneStruct:...:Innernode (from_u1/from_u2cross-wired, invisible tofindDanglingEdges). Addingunion_specifierletsbuildQualifiedNamepick up the named union'snamesegment → distinctU1.Inner/U2.Inner. Anonymous unions have nonamechild and correctly contribute nothing (members inject into the enclosing scope). The separate C config is untouched.Anonymous namespaces (commit 2)
An anonymous
namespace { }has nonamechild, so the scope walker dropped it (empty segment) and twonamespace { struct Inner {} }blocks collapsed. A C++extractScopeSegmentsoverride — the first consumer of the existing, unused config hook (generic.ts:98) — gives each anonymous namespace a deterministic per-block discriminator from its start byte. Named scopes (incl.inline namespace) and anonymous unions fall through unchanged. The discriminator is deterministic across the sequential and worker full-file parses, so the tests assert node distinctness (count==2 / distinct owner ids), never the non-portable discriminator value.Both fixes are C++-config-only — no shared-walker change, no language leak;
cClassConfig(C) is untouched.Tests
New
cpp-union-nested-tail-collisionandcpp-anon-ns-tail-collisionfixtures + tests mirroring the #1978 template:U1.Inner/U2.Innermaterialize as two distinct Struct nodes;from_u1/from_u2own through their own node.from_anon_a/from_anon_bown through distinct nodes.Verification
cppresolver suite: registry-primary 294/294, legacy 217 + 77 by-design skips — both green, including the worker path; the 8 new tests pass on both legs.tsc --noEmitclean; prettier clean.Closes #1995.
🤖 Generated with Claude Code