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.
Build environment: macOS 26.3 (
xs/v8from 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 bytesTarget device: desktop (host
xs)Description
Array.fromthrowsTypeError: callback: not a functionwhenmapfnis an explicitundefined. Per spec,undefinedmeans "no mapping", so the call should complete without error.Steps to Reproduce
Expected behavior
The expression evaluates to
[]with no exception thrown.For comparison, V8 (15.1.166):
Other information
This looks like a check on whether the
mapfnargument is present rather than what its value is. InArray.from,mapfnbeingundefinedshould setmappingto false and skip the callability check, so an explicitundefinedmust not throw. Withthisbeing0(not a constructor) and no"length"onToObject(0), the result should be an empty array.