Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c05343136dd6915718266d138dcdb303e7bff5f0
      
https://github.com/WebKit/WebKit/commit/c05343136dd6915718266d138dcdb303e7bff5f0
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-06-25 (Thu, 25 Jun 2026)

  Changed paths:
    A JSTests/stress/array-prototype-flat-nested-holes-prototype.js
    M Source/JavaScriptCore/runtime/JSArray.cpp

  Log Message:
  -----------
  [JSC] `Array#flat` fast path drops prototype-backed holes in nested arrays
https://bugs.webkit.org/show_bug.cgi?id=317823

Reviewed by Yusuke Suzuki.

JSArray::fastFlat checks holesMustForwardToPrototype() only on the
receiver. When calculateFlattenedLength / fastFlatIntoBuffer recurse
into a nested child array, the check is not repeated, so a child whose
prototype provides indexed properties (e.g. via Object.setPrototypeOf)
has its holes silently skipped instead of forwarding to the prototype
chain as FlattenIntoArray requires.

    let child = [, 1, 2];
    Object.setPrototypeOf(child, { 0: 99 });
    [child].flat();  // was [1, 2], should be [99, 1, 2]

Bail out to the slow path when a nested array's
holesMustForwardToPrototype() is true.

Test: JSTests/stress/array-prototype-flat-nested-holes-prototype.js

* JSTests/stress/array-prototype-flat-nested-holes-prototype.js: Added.
(shouldBe):
(shouldBeArray):
* Source/JavaScriptCore/runtime/JSArray.cpp:
(JSC::calculateFlattenedLength):
(JSC::fastFlatIntoBuffer):

Canonical link: https://commits.webkit.org/315806@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to