Skip to content

Bug: Array callbacks fail when function declares fewer params #8

@memburg

Description

@memburg

Summary

Array callback methods currently pass multiple arguments to callbacks, but user-defined function calls enforce exact arity. This causes JS-incompatible failures for common callback forms like array.map(function (x) { ... }).

Reproduction

var array = [1, 4, 9, 16];
var mapped = array.map(function (x) { return x * 2; });
console.log(mapped);

Current behavior

Error: function 'anonymous' expects 1 arguments but got 3

Expected behavior

JavaScript-compatible argument handling for callbacks:

  • extra callback arguments are ignored when the function declares fewer params
  • missing callback arguments are bound as undefined when the function declares more params

Notes

This affects callback-based methods added in issue #2 (forEach, map, filter, reduce, some, every, find, findIndex).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions