From 0a3cdce00e97cdff625cc92a7c743aff3d7b1ea6 Mon Sep 17 00:00:00 2001 From: marxo126 Date: Sun, 22 Mar 2026 11:37:02 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20address=20Copilot=20review=20=E2=80=94?= =?UTF-8?q?=20private(set)=20export,=20for-loop=20tuple=20pattern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Export detection: exclude private(set)/fileprivate(set) from unexported check. Only the setter is restricted — the symbol itself is still readable cross-file. 2. For-loop binding: use extractVarName() instead of raw .text to avoid polluting scopeEnv with non-identifier keys from tuple destructuring patterns (e.g. `for (a, b) in ...`). Co-Authored-By: Claude Opus 4.6 (1M context) --- gitnexus/src/core/ingestion/export-detection.ts | 4 +++- gitnexus/src/core/ingestion/type-extractors/swift.ts | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gitnexus/src/core/ingestion/export-detection.ts b/gitnexus/src/core/ingestion/export-detection.ts index 926669c41..dc02f4c4c 100644 --- a/gitnexus/src/core/ingestion/export-detection.ts +++ b/gitnexus/src/core/ingestion/export-detection.ts @@ -205,7 +205,9 @@ const swiftExportChecker: ExportChecker = (node, _name) => { while (current) { if (current.type === 'modifiers' || current.type === 'visibility_modifier') { const text = current.text || ''; - if (/\bprivate\b|\bfileprivate\b/.test(text)) return false; + // Exclude private(set)/fileprivate(set) — only the setter is restricted, + // the symbol itself is still readable cross-file. + if (/\b(private|fileprivate)\b(?!\s*\()/.test(text)) return false; } current = current.parent; } diff --git a/gitnexus/src/core/ingestion/type-extractors/swift.ts b/gitnexus/src/core/ingestion/type-extractors/swift.ts index 8634dc4dd..70e673084 100644 --- a/gitnexus/src/core/ingestion/type-extractors/swift.ts +++ b/gitnexus/src/core/ingestion/type-extractors/swift.ts @@ -340,8 +340,11 @@ const extractForLoopBinding: ForLoopExtractor = (node, { scopeEnv, declarationTy if (!child) continue; if (child.type === 'pattern' || child.type === 'simple_identifier') { if (!loopVarName) { - // The loop variable - may be inside a pattern node or a direct simple_identifier - loopVarName = child.type === 'pattern' ? child.text : child.text; + // Extract a simple identifier from the pattern. Skip non-trivial patterns + // (e.g. tuple destructuring `for (a, b) in ...`) to avoid polluting scopeEnv. + const varName = extractVarName(child) ?? (child.type === 'simple_identifier' ? child.text : undefined); + if (!varName) return; // Non-simple pattern — bail out + loopVarName = varName; continue; } }