Repository navigation
Commit c8c3731
[JSC] Array.prototype.toSpliced incorrectly throws TypeError instead of RangeError when length is Infinity
https://bugs.webkit.org/show_bug.cgi?id=320830
Reviewed by Yusuke Suzuki.
Array.prototype.toSpliced should throw TypeError when the new array
length exceeds 2**53-1 (Step 12 of [1]), but it currently throws
TypeError for the length of 2**53-1. For this case, it should throw
RangeError instead (Step 13 of [1], Step 1 of [2]).
To fix this, this commit replaces `>=` with `>` in the implementation
of `Array.prototype.toSpliced` to check the new array length.
[1]: https://tc39.es/ecma262/2026/multipage/indexed-collections.html#sec-array.prototype.tospliced
[2]: https://tc39.es/ecma262/2026/multipage/ordinary-and-exotic-objects-behaviours.html#sec-arraycreate
No additional tests. Instead, this commit also modify a exisiting
stress test to adjust the specification.
* JSTests/stress/change-array-by-copy.js:
(shouldThrow):
* Source/JavaScriptCore/runtime/ArrayPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
Canonical link: https://commits.webkit.org/320554@main1 parent a7cd2f5 commit c8c3731
2 files changed
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2245 | 2245 | | |
2246 | 2246 | | |
2247 | 2247 | | |
2248 | | - | |
| 2248 | + | |
2249 | 2249 | | |
2250 | 2250 | | |
2251 | 2251 | | |
| |||
0 commit comments