Skip to content

feat(resolver): push func-prop method names onto funcStack in extractSpreadForOfWalk #1373

Description

@carlos-alm

Problem

extractFuncPropMethodsWalk registers fn.method as a method definition, but extractSpreadForOfWalk's funcStack has no branch for the assignment_expression case (fn.method = function(){}).

When walking into that function_expression body, funcStack is empty (or holds the outer function), so any for-of loop inside emits a forOfBinding with enclosingFunc = '<module>' (or the wrong outer name). buildPointsToMap seeds pts['<module>::x'], but build-edges.ts only checks modulePtsKey when caller.callerName === null; for a call inside fn.method the callerName is 'fn.method', so the PTS key never matches and the for-of callback edges are silently dropped.

Repro

const callbacks = [doA, doB];
const obj = {};
obj.run = function() {
  for (const cb of callbacks) cb(); // cb() edge silently dropped
};

Fix

Add an else if (node.type === 'assignment_expression') branch in extractSpreadForOfWalk that extracts the method name from a member-expression LHS (mirroring handleFuncPropAssignment's logic) and pushes it onto funcStack.

Context

Identified in Greptile review of PR #1331.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions