Skip to content

XS: Array.from throws "callback: not a function" when mapfn is an explicit undefined #1645

Description

@d01c2

Build environment: macOS 26.3 (xs / v8 from jsvu)

Moddable SDK version: Installed via jsvu, so there is no SDK source tree / git describe. Engine reports: XS 17.9.1, slot 32 bytes, ID 4 bytes

Target device: desktop (host xs)

Description

Array.from throws TypeError: callback: not a function when mapfn is an explicit undefined. Per spec, undefined means "no mapping", so the call should complete without error.

Steps to Reproduce

$ xst -e "Array.from.call(0, 0, undefined);"
TypeError: callback: not a function (in Array.from)

Expected behavior

The expression evaluates to [] with no exception thrown.

For comparison, V8 (15.1.166):

$ v8 -e 'print(JSON.stringify(Array.from.call(0, 0, undefined)))'
[]

Other information

This looks like a check on whether the mapfn argument is present rather than what its value is. In Array.from, mapfn being undefined should set mapping to false and skip the callability check, so an explicit undefined must not throw. With this being 0 (not a constructor) and no "length" on ToObject(0), the result should be an empty array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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