Go: a local or parameter used as a value references a same-named package function
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #2776 của @colbymchenry — đã merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go, typescript
- Lĩnh vực
- compilers
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C
- Star
- 73.2k
- Fork
- 4.7k
- Merge trung bình
- 12 giờ 30 phút
- Pull request đã merge (30 ngày)
- 558
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của colbymchenry/codegraph
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
colbymchenry/codegraph#2770 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
colbymchenry/codegraph#2634 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows: bundled Node v24.16.0 can abort at exit (nodejs/node#56645); please bundle Node >= 24.20.0Có thể đã có người làm @Ancienttwo đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
colbymchenry/codegraph#2617 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
codegraph ui - does not workĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
colbymchenry/codegraph#1900 · 2 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
colbymchenry/codegraph#1700 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của colbymchenry/codegraph
Issue tương tự
-
area/ysql kind/enhancement priority/medium status/awaiting-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
yugabyte/yugabyte-db#35578 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Remove unused FVS_* macrosĐang mởinterpreter-core type-feature
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[onnx] update to 1.22.0Đang mởcategory:port-update
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày