Skip to content

XS: Array.from() returns an empty array instead of throwing when items is omitted #1665

Description

@d01c2

Build environment: macOS 26.5.2

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 returns an empty array when the required items argument is omitted. An omitted argument supplies undefined, so the call should throw a TypeError.

Steps to Reproduce

$ xst -e "print(JSON.stringify(Array.from()))"
[]

Expected behavior
A TypeError is thrown.

For comparison, V8 (15.3.27):

$ v8 -e "Array.from();"
TypeError: undefined is not iterable

Other information
XS already throws the expected error when undefined is passed explicitly:

$ xst -e "try { Array.from(undefined); } catch (e) { print(e.name); }"
TypeError

Metadata

Metadata

Assignees

No one assigned

    Labels

    conformancebehavior does not match standard

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions