Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Go: a local or parameter used as a value references a same-named package function

オープン
#2,596 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go, typescript
領域
compilers

調査の方向性

Start in src/extraction/tree-sitter.ts at flushFnRefCandidates, where Go function-value references are deduplicated per function and name. Reproduce with the apply(run) example, where a parameter shadows package-level func run, and check that use gets a references edge to function:run. Done means the shadowed use produces no edge to the package function, while a later unshadowed use in the same function still does. The issue leaves open whether to keep one ref per use or per scope, so agree that choice with the maintainers first.

索引モデルが issue の本文から書いたものです。

説明

Summary

In Go, using a local or parameter as a value, like apply(run) with a parameter run func(int, int) int, creates a references edge to a package-level func run that shares its name. The local shadows the package function there, so the edge is wrong. This is the value-use half of #2580; the PR for #2580 fixes bare calls only.

Reproduction (verified)

On main at c29caf2a, and on the #2580 branch, Linux, Node 22, CODEGRAPH_KERNEL=0:

package main

func run(a, b int) int { return a + b }

func apply(f any) {}

func use(run func(int, int) int) {
	apply(run)
}

func main() { use(nil) }

codegraph init -i gives use -references-> function:run. A local gives the same: run := 1; _ = run.

Expected: no edge from use to the package run.

Why the #2580 fix doesn't cover it

Dropping a shadowed value ref is not safe as things stand. The extractor records a Go function-value ref once per function and name (flushFnRefCandidates, inferred from reading the code). If the first use in a function is a shadowing local and a later use is the package function, dropping the first ref also loses the later, correct one. A fix needs one ref per use, or a dedupe that keeps a ref per scope.

Related: #2580.

主要言語
C
スター
73.2k
フォーク
4.7k
平均マージ
13時間 27分
マージ済み PR(30日)
518

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

colbymchenry/codegraph のほかの issue

colbymchenry/codegraph の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。