Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

TS/JS: a call in a parameter's default value (`f(x = build())`) gets no calls edge

Đang mở
#2,588 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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:

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_KERNEL unset). 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).
  • new expressions and references (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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của colbymchenry/codegraph

Tất cả issue của colbymchenry/codegraph

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.