Skip to content

[P2] Interpreter: Array.prototype.findLastIndex starts at the wrong index for long array-likes #3525

Open

Description

@nickna

The interpreter clamps the length used by Array.prototype.findLastIndex.call on an arguments object to 1,048,576. A predicate that matches the first index visited exposes the incorrect start index immediately.

function last() {
    arguments.length = 1048577;
    console.log(Array.prototype.findLastIndex.call(arguments, () => true));
}
last();

Node v22.23.2 and compiled SharpTS on clean main at cabb416 print 1048576. Interpreted SharpTS on the same commit prints 1048575. Run as an unchecked classic .js program using --no-tsconfig --noLib.

The generic callback path in ArrayBuiltIns.InvokeArrayLikeCallbackMethod clamps LengthOfArrayLike before iteration. This baseline interpretation bug was found while reproducing the separate compiled regression from the review of #3510.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions