Commit 4dc425c5 authored by legendecas's avatar legendecas Committed by V8 LUCI CQ

[builtins] TypedArray.prototype.set with number

Removes outdated type-error throwing on TypedArray.prototype.set
when the first argument is a number.

Bug: v8:11294
Change-Id: Ida3a46dec154b645620e2b064ded7a18de238649
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3136773Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76631}
parent a8506d94
......@@ -115,18 +115,6 @@ TypedArrayPrototypeSetArray(implicit context: Context, receiver: JSAny)(
IfDetached {
// Steps 9-13 are not observable, do them later.
// TODO(v8:8906): This ported behaviour is an observable spec violation and
// the comment below seems to be outdated. Consider removing this code.
try {
const _arrayArgNum = Cast<Number>(arrayArg) otherwise NotNumber;
// For number as a first argument, throw TypeError instead of silently
// ignoring the call, so that users know they did something wrong.
// (Consistent with Firefox and Blink/WebKit)
ThrowTypeError(MessageTemplate::kInvalidArgument);
} label NotNumber {
// Proceed to step 14.
}
// 14. Let src be ? ToObject(array).
const src: JSReceiver = ToObject_Inline(context, arrayArg);
......
......@@ -529,8 +529,10 @@ function TestTypedArraySet() {
assertThrows(function() { a.set.call({}) }, TypeError);
assertThrows(function() { a.set.call([]) }, TypeError);
assertThrows(function() { a.set(0); }, TypeError);
assertThrows(function() { a.set(0, 1); }, TypeError);
a.set(0);
assertArrayPrefix(expected, a);
a.set(0, 1);
assertArrayPrefix(expected, a);
assertEquals(1, a.set.length);
}
......
......@@ -609,8 +609,10 @@ function TestTypedArraySet() {
assertThrows(function() { a.set.call({}) }, TypeError);
assertThrows(function() { a.set.call([]) }, TypeError);
assertThrows(function() { a.set(0); }, TypeError);
assertThrows(function() { a.set(0, 1); }, TypeError);
a.set(0);
assertArrayPrefix(expected, a);
a.set(0, 1);
assertArrayPrefix(expected, a);
assertEquals(1, a.set.length);
......
......@@ -614,7 +614,7 @@ a61.set(a62)
assertArrayPrefix([1, 12], a61)
// Invalid source
assertThrows(function() { a.set(0); }, TypeError);
a.set(0); // does not throw
assertArrayPrefix([1,2,3,4,5,6], a);
a.set({}); // does not throw
assertArrayPrefix([1,2,3,4,5,6], a);
......
......@@ -416,8 +416,10 @@ function TestTypedArraySet() {
assertThrows(function() { a.set.call({}) }, TypeError);
assertThrows(function() { a.set.call([]) }, TypeError);
assertThrows(function() { a.set(0); }, TypeError);
assertThrows(function() { a.set(0, 1); }, TypeError);
a.set(0);
assertArrayPrefix(expected, a);
a.set(0, 1);
assertArrayPrefix(expected, a);
}
TestTypedArraySet();
......
......@@ -69,8 +69,6 @@
# https://code.google.com/p/v8/issues/detail?id=10958
'language/module-code/eval-gtbndng-indirect-faux-assertion': [FAIL],
'built-ins/TypedArray/prototype/set/array-arg-primitive-toobject': [FAIL],
'built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject': [FAIL],
# DataView functions should also throw on detached buffers
'built-ins/DataView/detached-buffer': [FAIL],
'built-ins/DataView/prototype/byteLength/detached-buffer': [FAIL],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment