feat: scope locals to their block in the type environment
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
調査の方向性
Start with LookupAt in internal/indexer/goextract/typeenv.go:89 and the test TestShadowedAliasResolvesByPosition in goextract/typeenv_test.go:92. Pick one of the name-only extractors, such as internal/indexer/mainstream/rustextract/typeenv.go:142, and add a shadow test where an inner-block local is followed by a call to the outer name. Done when that test passes and the outer name resolves after the block closes.
索引モデルが issue の本文から書いたものです。
説明
What exists today?
Each extractor's type environment finds a receiver's type by name. Four extractors also check the position of the call.
- Go:
internal/indexer/goextract/gotypeenv.go:146callsLookupAt. - TypeScript:
internal/indexer/tsextract/typeenv.go:139callsLookupAt. - Java:
internal/indexer/javaextract/typeenv.go:132callsLookupAt. - C#:
internal/indexer/csharpextract/typeenv.go:161callsLookupAt.
LookupAt is defined at internal/indexer/goextract/typeenv.go:89. It returns the latest declaration whose scope holds the position.
Seven other lookups use the name-only Lookup, which ignores the position:
- Python:
internal/indexer/pyextract/typeenv.go:164 - Ruby:
internal/indexer/mainstream/rubyextract/typeenv.go:96 - PHP:
internal/indexer/mainstream/phpextract/typeenv.go:163 - Kotlin:
internal/indexer/mainstream/kotlinextract/typeenv.go:164 - Swift:
internal/indexer/mainstream/swiftextract/typeenv.go:140 - Rust:
internal/indexer/mainstream/rustextract/typeenv.go:142 - C and C++:
internal/indexer/mainstream/cextract/typeenv.go:175
A whole-body lookup is wrong only where the language ends a local at a block. Kotlin, Swift, Rust, C and C++ do. Ruby ends a local at a do or brace block, but not at if. Python and PHP have no block scope, so a local hides an outer name for the whole function. internal/indexer/goextract/scope.go:68 records the PHP rule.
No fixture covers a block-scoped shadow in these seven extractors yet.
How does it behave now?
Reading internal/indexer/mainstream/rustextract/typeenv.go:142, the lookup ignores the block. A local declared in an inner block still answers a call after that block closes. This is from reading the code. A run of the Rust extractor on a shadow fixture has not been done.
How should it behave?
Each extractor scopes a local by its language's rule:
- Kotlin, Swift, Rust, C and C++: from the declaration to the end of the enclosing block.
- Ruby: from the declaration to the end of the enclosing
door brace block. - Python and PHP: whole-function scope, which the language defines.
A call resolves to the declaration whose scope holds its position, as LookupAt does for Go. A call after an inner block resolves to the outer name again.
Add one shadowing test per extractor, modelled on TestShadowedAliasResolvesByPosition at internal/indexer/goextract/typeenv_test.go:92. Each test declares an inner-block local, then calls the outer name after the block. The test asserts the outer resolution. The Python and PHP tests assert whole-function scope, so the rule stays fixed.
The spec in openspec/specs/graph-index/spec.md already requires this. Its requirement is "A same-file reference resolves by lexical scope." The design of the per-body type environment is in openspec/changes/archive/2026-11-02-index-invariants/design.md, decision D17.
Would this change existing behavior?
Yes. Some calls that resolve today to an inner-block local will resolve to the outer name, or stay unresolved. The output shape does not change.
What kind of improvement?
Correctness in an edge case
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/
- 主要言語
- 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
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
automated documentation maintenance
難易度 1/5 1〜3時間 初心者へのやさしさ 75/100
github/gh-aw-mcpg#16717 ·
メンテナーはふだん 1 日以内に返信
-
Docs: Recording rules pages don't say what happens to a recorded metric when its rule is deletedオープンinternal
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
jesseduffield/lazygit#6229 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
prometheus/prometheus#20482 ·
メンテナーはふだん 2 日以内に返信