Skip to content

XS: value and done on iterator result objects are non-writable and non-configurable #1687

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
The value and done properties of an iterator result object are created as non-writable and non-configurable.

CreateIteratorResultObject adds both with CreateDataPropertyOrThrow, which builds the descriptor { [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }, so both properties must be writable and configurable.

Steps to Reproduce

$ xst -e 'print(JSON.stringify(Object.getOwnPropertyDescriptor((function*(){})().next(), "value")))'
{"writable":false,"enumerable":true,"configurable":false}

Expected behavior

{"writable":true,"enumerable":true,"configurable":true}

For comparison, V8 (15.4.18):

$ v8 -e 'print(JSON.stringify(Object.getOwnPropertyDescriptor((function*(){})().next(), "value")))'
{"writable":true,"enumerable":true,"configurable":true}

Other information
done has the same descriptor, and every iterator result object is affected, not only generators. The results of the array, string, Map, Set, RegExp string and iterator helper next methods all report writable: false, configurable: false. The difference reaches ordinary code, since writing to the result throws in strict mode:

$ xst -e '"use strict"; var r = [1].values().next(); r.value = 9;'
TypeError: set value: not writable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions