Skip to content

fix(callgraph): arrow functions as object-literal values not tracked, undercounts ref_count #222

Description

@Wolfvin

Mengapa

Ditemukan oleh worker saat mengerjakan issue #210 (sudah closed via PR #219). PR #221 (closed, konflik dengan #219 yang sudah merge duluan) menemukan gap TERPISAH yang belum ter-cover oleh fix #219: arrow function yang jadi value di object-literal pair (const service = { list: (ctx) => {...}, create: (ctx) => {...} }) tidak pernah terdaftar sebagai node, jadi calls di dalam body-nya invisible ke reference counting.

Reproduksi worker (sebelum fix, TS parser):

export const assignmentService = {
  list: (ctx) => { if (!hasPermission(ctx.user, 'read')) return null; return []; },
  create: (ctx) => { if (!hasPermission(ctx.user, 'write')) throw new Error('no'); return {}; },
};
Output parser: nodes=0, edges=0

_parse_variable_declarator di ts_backend_parser.py/js_backend_parser.py hanya handle value berupa arrow_function/function_expression/defineStore(...) call langsung — kalau value adalah object node (object literal), return None, dan arrow function di dalam pair-nya tidak pernah diregister.

Konteks

Pattern ini umum untuk "service object" / "handler map" style code (grouping related functions sebagai object daripada named exports terpisah) — mirip Pinia defineStore yang SUDAH dihandle khusus di fix #219, tapi object-literal biasa (tanpa defineStore) belum.

Tujuan

Tambah dukungan: kalau variable_declarator's value adalah object literal (object node type), walk semua property/pair yang value-nya arrow_function/function_expression, register sebagai node dengan nama <varName>.<key> (persis seperti approach worker: assignmentService.list, assignmentService.create), supaya calls di dalam body-nya ter-collect dengan benar.

Constraint

Definition of Done

  1. Reproduksi kasus di atas (const service = {method: (ctx) => {...}}) — call di dalam method ter-extract dengan benar
  2. search --mode symbol untuk fungsi yang dipanggil hanya lewat pattern ini menunjukkan rc yang benar (bukan 0)
  3. Tidak ada regresi terhadap fix fix(callgraph): extract module-top-level calls to fix rc undercount (closes #210) #219 (module-scope calls, inline arrow callback di argument) — test suite terkait harus tetap pass
  4. Minimal 2 unit test baru (TS + JS) yang reproduce pattern object-literal-arrow-function

Checklist Laporan Worker

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions