mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb/WebIDL: Throw correct error when converting integers
When an integer doesn't fit within the range of an integral type defined by WebIDL, the spec says to throw a `TypeError`, not a `RangeError`.
This commit is contained in:
parent
4e7d3026d2
commit
3be7e88903
Notes:
github-actions[bot]
2024-08-18 21:36:08 +00:00
Author: https://github.com/dzfrias Commit: https://github.com/LadybirdBrowser/ladybird/commit/3be7e889031 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1105 Reviewed-by: https://github.com/alimpfard
2 changed files with 2 additions and 2 deletions
|
@ -1,3 +1,3 @@
|
|||
Made memory [object WebAssembly.Memory] with buffer [object ArrayBuffer] (byteLength 655360)
|
||||
After growing buffer (byteLength 983040)
|
||||
Got error: 'RangeError: Number '4294967296' is outside of allowed range of 0 to 4294967295'
|
||||
Got error: 'TypeError: Number '4294967296' is outside of allowed range of 0 to 4294967295'
|
||||
|
|
|
@ -384,7 +384,7 @@ JS::ThrowCompletionOr<T> convert_to_int(JS::VM& vm, JS::Value value, EnforceRang
|
|||
|
||||
// 3. If x < lowerBound or x > upperBound, then throw a TypeError.
|
||||
if (x < lower_bound || x > upper_bound)
|
||||
return vm.throw_completion<JS::RangeError>(MUST(String::formatted("Number '{}' is outside of allowed range of {} to {}", x, lower_bound, upper_bound)));
|
||||
return vm.throw_completion<JS::TypeError>(MUST(String::formatted("Number '{}' is outside of allowed range of {} to {}", x, lower_bound, upper_bound)));
|
||||
|
||||
// 4. Return x.
|
||||
return x;
|
||||
|
|
Loading…
Reference in a new issue