Skip to content

fix(resolver): scope Phase 8.3f typeMap key by function to avoid same-name rest-param collision #1358

Description

@carlos-alm

Problem

Both the WASM (buildCallEdgesJS) and native (buildObjectRestParamPostPass) Phase 8.3f seeding paths key the typeMap entry by restName alone (e.g. rest):

typeMap.set(orpb.restName, { type: pb.argName, confidence: 0.65 });

If two functions in the same file both use ...rest as their rest binding:

function f1({ a, ...rest }) { rest.method(); }
function f2({ b, ...rest }) { rest.method(); }
f1(obj1);
f2(obj2);

The first seeding wins via the !typeMap.has(restName) guard, so f2's rest binding resolves to obj1 instead of obj2.

Fix

Scope the typeMap key to include the enclosing function name (e.g. f1::rest). The resolution path in resolveByMethodOrGlobal would then need to look up the scoped key using the current caller context.

This requires coordinated changes in both the seeding and the resolution lookup.

Scope

Out of scope for PR #1355 (Phase 8.3f). Affects both WASM and native paths equally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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