Bug 271703
Summary: | Array.fromAsync calls Array constructor twice | ||
---|---|---|---|
Product: | WebKit | Reporter: | Sosuke Suzuki <aosukeke> |
Component: | JavaScriptCore | Assignee: | 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
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Sosuke Suzuki
Pull request: https://github.com/WebKit/WebKit/pull/26459
EWS
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
<rdar://problem/125509304>