[Webkit-unassigned] [Bug 271703] New: Array.fromAsync calls Array constructor twice

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Mar 26 06:06:47 PDT 2024


https://bugs.webkit.org/show_bug.cgi?id=271703

            Bug ID: 271703
           Summary: Array.fromAsync calls Array constructor twice
           Product: WebKit
           Version: WebKit Local Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: aosukeke at gmail.com

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);
});
```

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240326/4fda0c52/attachment-0001.htm>


More information about the webkit-unassigned mailing list