TS/JS: a call in a parameter's default value (`f(x = build())`) gets no calls edge
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript, wasm
- Lĩnh vực
- devtools
Hướng nghiên cứu
Start with the repro in the issue: a TypeScript file whose function has a parameter default containing a call, indexed with the WASM extractor. The two places named are extractFunction and extractMethod in src/extraction/tree-sitter.ts, which push the function node and walk only its body. Done means the calls edge from renderWithNote, the arrow function, K.m and destr to buildNote appears, and the existing in-body call edges still pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
A call written in a parameter default — function renderWithNote(note = buildNote()) — is not extracted at all: no calls edge and no unresolved reference. The same holds for arrow functions, class methods and destructured parameters with a default. buildNote therefore shows no caller from renderWithNote, and an impact query on buildNote misses it.
Reproduction (verified)
On main at 8fe31569, built from source, Linux (WSL2), Node 22.23.2, WASM extractor (CODEGRAPH_KERNEL=0).
src/f.ts
export function buildNote() { return { id: 1 }; }
export function renderWithNote(note = buildNote()) {
return note.id;
}
codegraph init -i, then every edge that is not contains / imports / exports, and the unresolved refs:
-- edges
(none)
-- unresolved refs
(none)
The same empty result for:
export const arrow = (note = buildNote()) => note.id;
export class K { m(note = buildNote()) { return note.id; } }
export function destr({ n } = buildNote() as any) { return n; }
Control, same file: export function inBody() { const note = buildNote(); return note.id; } gets inBody -[calls L5]-> buildNote, so the call is only lost when it sits in a default.
Observed: no edge from renderWithNote (or arrow, K.m, destr) to buildNote.
Expected: renderWithNote -[calls]-> buildNote. A default is evaluated on every call that omits the argument, inside the function's own scope.
Likely cause (inferred from reading the code)
The grammar does put the call under the parameter ((required_parameter pattern: (identifier) value: (call_expression ...))), but the extractor pushes the function node and walks only its body:
- https://github.com/colbymchenry/codegraph/blob/8fe31569926680af6e5e7d616bf178a6fee053c7/src/extraction/tree-sitter.ts#L2023-L2029 (
extractFunction) - https://github.com/colbymchenry/codegraph/blob/8fe31569926680af6e5e7d616bf178a6fee053c7/src/extraction/tree-sitter.ts#L2289-L2296 (
extractMethod)
I did not find any other place that visits the value of a required_parameter / optional_parameter / assignment_pattern for calls, which matches the empty unresolved_refs above (the call is never seen, rather than seen and left unresolved). Visiting each parameter's default value while the function node is still on nodeStack would attribute the call to the function.
Related
None found.
Not checked
- The Rust kernel path (default,
CODEGRAPH_KERNELunset). Only the WASM extractor was run. - Other languages with default argument expressions (Python's
def f(x=build())is evaluated at definition time, so the right caller there is the enclosing scope rather than the function; Kotlin, Swift, C#, PHP and Ruby evaluate per call like JS). newexpressions andreferences(e.g.x = DEFAULT_CONST) in default values, which are probably missed the same way.
- Ngôn ngữ chính
- C
- Star
- 73.2k
- Fork
- 4.7k
- Merge trung bình
- 4 giờ 46 phút
- Pull request đã merge (30 ngày)
- 478
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 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 4 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
-
Invalid regular expression: /\boperator++\s*(?:<[^<>()]*>)?\s*\(/: Nothing to repeat (v1.6.2)Đang mở
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 72/100
colbymchenry/codegraph#2482 · 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ự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 71/100
awslabs/aws-checksums#121 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Bad tag for language cardĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
bug low priority rt_lib wasm
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày