Skip to content

Array.prototype.map on a Proxy-wrapped array throws 'Cannot convert undefined or null to object' #5196

@proggeramlug

Description

@proggeramlug

Perry: origin/main @ a1d9ce6 (v0.5.1174) · macOS arm64
Build/run: perry repro.ts -o out && ./out

Bug

Array.prototype.map (and likely other Array methods) called on a Proxy-wrapped array throws TypeError: Cannot convert undefined or null to object. Individual proxy traps work; the array-method-on-proxy path does not.

Surfaced after #5129 (the Proxy set/Reflect.set segfault fix) — the fuller proxy case now gets past the set trap and dies here instead.

Repro

const arr = new Proxy([1, 2, 3] as number[], { get(t, k, r) { return Reflect.get(t, k, r); } });
console.log(arr.map((x) => x * 10).join(","));

Expected (Node)

10,20,30

Actual (Perry)

TypeError: Cannot convert undefined or null to object

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    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