Skip to content

[P2] Compiler: Array.prototype.some skips indexed accessors on arguments #3523

Open

Description

@nickna

On clean main at cabb416, the compiler bypasses an indexed getter on a strict function's arguments object when Array.prototype.some.call visits that index.

function visit() {
    "use strict";
    const trace = [];
    Object.defineProperty(arguments, "0", { get() { trace.push("get0"); return 1; } });
    Object.defineProperty(arguments, "1", { get() { trace.push("get1"); return 2; } });
    const result = Array.prototype.some.call(arguments, (value, index) => {
        trace.push("callback" + index);
        return value === 1;
    });
    console.log(result, trace.join(","));
}
visit(1, 2);

Node v22.23.2 and SharpTS interpretation print true get0,callback0. Compiled clean main passes full --verify and prints false with an empty trace. Run as an unchecked classic .js program using --no-tsconfig --noLib.

Related to #3520 and surfaced in the review of #3510.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions