Skip to content

Make Array.fromAsync elements enumerable#1581

Merged
saghul merged 1 commit into
quickjs-ng:masterfrom
littledivy:fix/fromasync-enumerable
Jul 17, 2026
Merged

Make Array.fromAsync elements enumerable#1581
saghul merged 1 commit into
quickjs-ng:masterfrom
littledivy:fix/fromasync-enumerable

Conversation

@littledivy

Copy link
Copy Markdown
Contributor

Array.fromAsync built its result with Object.defineProperty and no enumerable flag, so the elements defaulted to non-enumerable. The spec adds them with CreateDataPropertyOrThrow, which creates enumerable own data properties, so Object.keys(), spread and for-in should see them.

const arr = await Array.fromAsync([10, 20, 30]);
Object.keys(arr);                               // before: []   after: ["0","1","2"]
Object.getOwnPropertyDescriptor(arr, 0).enumerable; // before: false  after: true
descriptor field before after
value
writable true true
configurable true true
enumerable false true

Disclaimer: This is an AI-assisted patch from the v8x project.

Array.fromAsync built its result with Object.defineProperty and no
`enumerable` flag, so the elements defaulted to non-enumerable. The spec
adds them with CreateDataPropertyOrThrow, which creates enumerable own
data properties. As a result Object.keys(), spreads and for-in saw an
empty array.

Add `enumerable: true` to the property definitions and regenerate the
precompiled builtin.
@saghul
saghul merged commit 28e44d3 into quickjs-ng:master Jul 17, 2026
128 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants