Skip to content

fix(cpp): resolve cross-namespace same-tail inheritance bases bridge-held (#1993)#2002

Closed
magyargergo wants to merge 2 commits into
abhigyanpatwari:mainfrom
magyargergo:fix/1993-cpp-ns-qualified-inheritance
Closed

fix(cpp): resolve cross-namespace same-tail inheritance bases bridge-held (#1993)#2002
magyargergo wants to merge 2 commits into
abhigyanpatwari:mainfrom
magyargergo:fix/1993-cpp-ns-qualified-inheritance

Conversation

@magyargergo

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #1981 / #1982. PR #1981 landed a targeted bridge (tagNamespacePrefixes + a resolveDefGraphId namespace-prefixed retry) that fixes the within-namespace same-tail heritage case (NS::A::Inner vs NS::B::Inner, distinguished by the class chain). The residual: a cross-namespace same-tail base (NS1::A::Inner vs NS2::A::Inner) — both key the namespace-omitted A.Inner in the qualifiedNames resolution index, so resolveQualifiedInheritanceBase could not pick a winner and the deriving classes cross-wired (DB's EXTENDS bound to NS1's A::Inner).

Fixed bridge-held — without flipping the class-chain-only qualifiedName invariant (which would re-bite two-phase lookup / UDC / brace-init) and without re-keying the resolution index.

Fix

The namespacePrefix sidecar (set by tagNamespacePrefixes, deliberately separate from qualifiedName) already records each namespaced def's enclosing namespace. Two sidecar-only changes:

  1. tagNamespacePrefixes now also tags defs declared directly in a namespace (e.g. the deriving NS1::DA), composed identically to the existing class-nested path. The original loop only reached class-nested defs (A::Inner).
  2. resolveQualifiedInheritanceBase, on a same-tail tie at a key, breaks the tie by preferring the candidate whose namespacePrefix matches the deriving class's — the base in the same enclosing namespace. It still refuses when the sidecar can't pick a unique.

def.qualifiedName and the qualifiedNames index keys are untouched, so two-phase lookup, UDC ranking, brace-init, and file-local linkage are unaffected. The deferred root-cause work (making qualifiedName namespace-inclusive and removing the bridge) is unchanged and out of scope.

Tests

New cpp-cross-namespace-same-tail fixture + test (registry-primary, in the cpp parity expected-failures like the #1982 namespaced tests): NS1.DA EXTENDS NS1.A.Inner and NS2.DB EXTENDS NS2.A.Inner — positive base-identity by the resolved node's qualifiedName, which fails pre-fix (DB cross-wired to NS1.A.Inner).

Verification

Closes #1993.

🤖 Generated with Claude Code

…held (abhigyanpatwari#1993)

PR abhigyanpatwari#1981's bridge fixed within-namespace same-tail heritage (NS::A::Inner vs NS::B::Inner). The residual: a cross-namespace same-tail base (NS1::A::Inner vs NS2::A::Inner) both key the namespace-omitted `A.Inner` in the qualifiedNames index, so resolveQualifiedInheritanceBase couldn't pick a winner and the deriving classes cross-wired (DB's EXTENDS bound to NS1's A::Inner).

Fixed bridge-held via the existing `namespacePrefix` sidecar — no qualifiedName invariant flip, no resolution-index re-keying: (1) tagNamespacePrefixes also tags defs declared directly in a namespace (the deriving NS1::DA), composed identically to the class-nested path; (2) resolveQualifiedInheritanceBase breaks a same-tail tie by preferring the candidate whose namespacePrefix matches the deriving class's. Two-phase lookup, UDC, brace-init, file-local linkage untouched (def.qualifiedName + index keys unchanged).

New cpp-cross-namespace-same-tail fixture + registry-primary test (in the cpp parity expected-failures). Verified: cpp suite 287/287 primary, 209 + 78 skips legacy — no regression; tsc + prettier clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 3, 2026

Copy link
Copy Markdown

@magyargergo is attempting to deploy a commit to the NexusCore Team on Vercel.

A member of the Team first needs to authorize it.

@magyargergo

Copy link
Copy Markdown
Collaborator Author

Superseded by same-repo stacked PR #2005.

@magyargergo magyargergo closed this Jun 3, 2026
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

CI Report

Some checks failed

Pipeline Status

Stage Status Details
✅ Typecheck success tsc --noEmit
❌ Tests failure unit tests, 3 platforms
✅ E2E success gitnexus-web changes only

Test Results

Tests Passed Failed Skipped Duration
11057 11041 0 16 697s

✅ All 11041 tests passed

16 test(s) skipped — expand for details
  • COBOL pipeline benchmark > scales with file count
  • C++ ADL emit benchmark > emit phase scales sub-quadratically with co-scaled files and sites
  • C++ pipeline benchmark > scales with file count
  • C# pipeline benchmark > scales with file count — namespaces spread across the solution
  • C# pipeline benchmark > scales with file count — all types in one (global) namespace bucket
  • C# pipeline benchmark > scales with file count — all types in one (named) namespace bucket
  • Go pipeline benchmark > scales with file count (workers enabled)
  • Go pipeline benchmark — worker pool (issue Worker idle timeout kills long Go scope extraction and surfaces as Napi::Error during analyze #1848) > does not quarantine the large generated Go file on sub-batch idle timeout
  • Go structural interface detection benchmark > scales linearly with interface × struct count
  • Go structural interface detection split-phase benchmark > separates index-build and detection time
  • PHP pipeline benchmark > scales with file count (workers enabled)
  • Ruby pipeline benchmark > scales with file count (workers enabled)
  • Rust pipeline benchmark > scales with file count (workers enabled)
  • Vue pipeline benchmark > scales with component count
  • run.cjs direct-exec entrypoint (fix(cli): steer docs, skills, and hooks through a CLI-neutral project-local runner (#1939) #1945) > resolves a .cmd shim via the Windows shell branch, passing args and exit code
  • buildTypeEnv > known limitations (documented skip tests) > Ruby block parameter: users.each { |user| } — closure param inference, different feature

Code Coverage

Tests

Metric Coverage Covered Base Delta Status
Statements 80.33% 38724/48204 79.84% 📈 +0.5 🟢 ████████████████░░░░
Branches 68.88% 24613/35731 68.5% 📈 +0.4 🟢 █████████████░░░░░░░
Functions 85.55% 4034/4715 84.94% 📈 +0.6 🟢 █████████████████░░░
Lines 83.94% 34835/41496 83.36% 📈 +0.6 🟢 ████████████████░░░░

📋 View full run · Generated by CI

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cpp): scope-model def.qualifiedName drops the enclosing namespace (root cause behind #1982's targeted heritage bridge)

1 participant