feat: Go extractor records no read of a composite-literal element value
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start in internal/indexer/goextract/goextract.go: the composite_literal case of captureExprRead (~1184) delegates to captureCompositeElements (~1249) and captureElementWrites (~1277), which only record field writes. Add a read for each element value (bare identifier, selector, call, nested literal) across slice, struct, map-key and map-value positions, and fix the stale comment at 956-962. Check behavior with the p.go repro and internal/indexer/bindings_test.go, then run task golden:regen and task corpora:measure and update the hugo goldens, corpora/observations.json, docs/CORPUS-MEASUREMENT.md, matrix.go:101 and docs/LANGUAGE-CAPABILITY-MATRIX.md:126.
索引モデルが issue の本文から書いたものです。
説明
What exists today?
internal/indexer/goextract/goextract.go records no read for a value that a composite literal element holds.
How does it behave now?
Repro in a file p.go:
package p
type T struct{ F int }
func f(v, a, b int) {
_ = T{F: v}
_ = []int{a, b}
_ = map[int]int{a: b}
}
f gets a write reference to F and an instantiates reference to T. f gets no read reference to v, a or b. The map key a gets no read either.
The cause is in the composite-literal path:
collectReferencesAndInstantiatessends acomposite_literaltocaptureExprReadand stops (goextract.go:986).- The
composite_literalcase ofcaptureExprRead(goextract.go:1184-1188) callsrecordInstantiateandcaptureCompositeElements. It never reads an element value. captureCompositeElements(goextract.go:1249-1272) records only anAccessWritemember reference for a keyed element.captureElementWrites(goextract.go:1277-1299) acts only onliteral_value,composite_literalandunary_expression. A bare identifier, selector or call records nothing.captureExprReadhas noliteral_elementcase.
The block comment at goextract.go:956-962 says element values are read positions. The code does not do that, so the comment is stale.
The gap is recorded as a known limit in internal/indexer/capability/matrix.go:101 and docs/LANGUAGE-CAPABILITY-MATRIX.md:126. #342 left it open because recording the reads changes explore ranking and a hugo golden.
Effect: codegraph node and callers-style read queries miss these reads. The planned Accessed by ← line in #335 misses them too.
How should it behave?
A composite-literal element value records a read reference from the enclosing function. This covers bare identifiers, selectors, calls and nested literals, in slice elements, struct fields, map keys and map values. A keyed struct element still records its write to the field.
For the repro, f gets read references to v, a and b. It keeps the write to F and the instantiates reference to T.
The same change must fix the stale comment at goextract.go:956-962.
The fix changes these artifacts, and the PR must update each one:
- Hugo goldens under
testdata/golden/corpus/hugo/(go-explore*.json, probablygo-node*.json), checked byTestGoldensMatchLiveEngineOutput. corpora/observations.jsonanddocs/CORPUS-MEASUREMENT.md.- The matrix entries at
matrix.go:101anddocs/LANGUAGE-CAPABILITY-MATRIX.md:126.
Whether TestExtract_Instantiates, TestExtract_InstantiatesUnnamedTypeNoRef or TestGoFieldWritesWithholdCalls (internal/indexer/bindings_test.go) needs changes is open until the fix runs.
Run task golden:regen and task corpora:measure in the same PR.
What kind of improvement?
Correctness in an edge case
Would this change existing behavior?
Yes. Each composite-literal element adds a read reference, so these outputs change:
codegraph nodeand callers-style read queries list more readers.- Explore ranking changes, which regenerates the hugo goldens.
The output shapes stay the same. Only the set of read entries changes.
Before submitting
- I searched existing issues and this is not a duplicate
- I checked that the current behavior is not a deliberate decision in
openspec/specs/
🤖 Generated with Claude Code
- 主要言語
- Go
- スター
- 0
- フォーク
- 0
- 平均マージ
- 7時間 42分
- マージ済み PR(30日)
- 111
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
seanb4t/codegraph-go のほかの issue
-
chore needs-triage
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
seanb4t/codegraph-go#380 ·
メンテナーはふだん 1 日以内に返信
-
chore needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
seanb4t/codegraph-go#379 ·
メンテナーはふだん 1 日以内に返信
-
area:query chore needs-triage spec-needed
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
seanb4t/codegraph-go#377 ·
メンテナーはふだん 1 日以内に返信
-
chore needs-triage
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
seanb4t/codegraph-go#362 ·
メンテナーはふだん 1 日以内に返信
-
area:query bug needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
seanb4t/codegraph-go#355 ·
メンテナーはふだん 1 日以内に返信
seanb4t/codegraph-go の issue をすべて見る
似ている issue
-
Add iterate GmbH domains to a dedicated list and include it in company and developer categoriesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
v2fly/domain-list-community#4307 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
notify: voice_queue rows are deleted only at startup, so a hub that stays up grows it without boundオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mattabate/life-distributable#232 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信