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}
17 lines
584 B
JavaScript
17 lines
584 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;
|
|
}
|
|
|
|
// This iterates over arr using the iterator protocol, which turns the hole into
|
|
// undefined. The mapper function then gets called in a separate iteration over
|
|
// the acquired elements, where it increments undefined, which produces NaN and
|
|
// gets converted to 0.
|
|
assertArrayEquals([2, 0, 4], Uint16Array.from(arr, mapper));
|