Check k >= 2**53-1 in Array.from.

NEW
Unassigned

Status

()

P5
minor
2 years ago
10 days ago

People

(Reporter: arai, Unassigned)

Tracking

({triage-deferred})

Trunk
triage-deferred
Points:
---

Firefox Tracking Flags

(firefox53 affected)

Details

(URL)

(Reporter)

Description

2 years ago
Currently, step 5.e.i is not implemented (intentionally),
since it causes performance regression, and also we won't hit it in almost all cases.

> i. If k >= 2**53-1, then
>     1. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created
>        TypeError object, [[Target]]: empty}.
>     2. Return ? IteratorClose(iterator, error).


If we're using normal Array, the step viii will throw before reaching 2**53-1 elements.

> viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue).


The situation happens only if we're using suclassed Array that returns Proxy from ctor that ignores defineProperty, and also passing custom iterator that yield infinitely.

  class MyArray extends Array {
    constructor() {
      return new Proxy({}, {
        defineProperty() { return true; }
      });
    }
  }
  try {
    MyArray.from({
      [Symbol.iterator]() {
        let v = { value: 1, done: false };
        return { next() { return v; } };
      }
    });
  } catch (e) {
  }

it will take too long time before hitting 2**53-1-th element


So, it's not important to implement the step.
We could add it if we can remove the performance impact.
Keywords: triage-deferred
Priority: -- → P3
(Reporter)

Updated

10 days ago
Priority: P3 → P5
You need to log in before you can comment on or make changes to this bug.