4a75168479
This is an unmodified reland of ece86adc6b
.
Original change's description:
> [typedarray] Properly convert hole to undefined in TypedArray.from
>
> It used to call the old IterableToList, which had the wrong
> semantics for holes.
>
> Bug: v8:8133
> Change-Id: Idd5acd55a155bc43df7552135a44151bb2db38e9
> Reviewed-on: https://chromium-review.googlesource.com/1213204
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
> Commit-Queue: Georg Neis <neis@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#55745}
Tbr: petermarshall@chromium.org
Bug: v8:8133
Change-Id: I91c1eaf61cbcc29116e3a6cc3415f29cfba3561e
Reviewed-on: https://chromium-review.googlesource.com/1223007
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55846}
18 lines
619 B
JavaScript
18 lines
619 B
JavaScript
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
const arr = [1, , 3];
|
|
|
|
function mapper(x) {
|
|
Array.prototype[1] = 2;
|
|
return x + 1;
|
|
}
|
|
|
|
// We force a direct iteration (using the array length, not the iterator
|
|
// protocol). The mapper function gets called during this iteration, not in a
|
|
// separate one. Hence when index 1 is read, 2 is retrieved from the prototype
|
|
// and incremented to 3.
|
|
Array.prototype[Symbol.iterator] = undefined;
|
|
assertArrayEquals([2, 3, 4], Uint16Array.from(arr, mapper));
|