Bug 271703

Summary: Array.fromAsync calls Array constructor twice
Product: WebKit Reporter: Sosuke Suzuki <aosukeke>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   

Sosuke Suzuki
Reported 2024-03-26 06:06:47 PDT
When executing `Array.fromAsync.call(MyArray, { length: 2, 0: 1, 1: 2 });`, the `MyArray` constructor is called twice by `Array.fromAsync`. This bug is the cause of the failure of the Array.fromAsync test case in test262 (ref: https://github.com/WebKit/WebKit/blob/d03ff2b610bca99b7a8160d654e35297218ff64a/JSTests/test262/expectations.yaml#L4-L9). poc: ```js function shouldBe(actual, expected) { if (actual !== expected) throw new Error("bad value: " + actual); } let callCount = 0; function MyArray(...args) { callCount++; return new Proxy(Object.create(null), { set(target, key, value) { return Reflect.set(target, key, value); }, defineProperty(target, key, descriptor) { return Reflect.defineProperty(target, key, descriptor); }, }); } (async () => { await Array.fromAsync.call(MyArray, { length: 2, 0: 1, 1: 2 }); })().then(() => { shouldBe(callCount, 1); }); ```
Attachments
Sosuke Suzuki
Comment 1 2024-03-26 06:09:51 PDT
EWS
Comment 2 2024-03-27 14:07:06 PDT
Committed 276752@main (75d98d9e2d74): <https://commits.webkit.org/276752@main> Reviewed commits have been landed. Closing PR #26459 and removing active labels.
Radar WebKit Bug Importer
Comment 3 2024-03-27 14:08:14 PDT
Note You need to log in before you can comment on or make changes to this bug.