mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +00:00
LibJS: Let Array.prototype.toSpliced throw RangeError for len <= 2^53-1
This aligns it with the spec again, it was clarified that the additional range check before ArrayCreate is intentional: https://github.com/tc39/proposal-change-array-by-copy/issues/94 Also cast the final variable to an u64 instead of size_t after we have determined that it is safe to do so, as that's what Array::create() takes now.
This commit is contained in:
parent
5927cdd9c5
commit
4b70ddf5a0
2 changed files with 9 additions and 5 deletions
|
@ -97,4 +97,11 @@ describe("errors", () => {
|
|||
Array.prototype.toSpliced.call(a, 0, 0, "foo");
|
||||
}).toThrowWithMessage(TypeError, "Maximum array size exceeded");
|
||||
});
|
||||
|
||||
test("invalid array length", () => {
|
||||
const a = { length: 2 ** 32 - 1 };
|
||||
expect(() => {
|
||||
Array.prototype.toSpliced.call(a, 0, 0, "foo");
|
||||
}).toThrowWithMessage(RangeError, "Invalid array length");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue