mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:37:35 +00:00
LibJS: Use Value::to_index() in typed array constructors
This commit is contained in:
parent
eaa85969c4
commit
cf9da66b3e
1 changed files with 6 additions and 5 deletions
|
@ -77,13 +77,14 @@ namespace JS {
|
||||||
/* FIXME: Initialize from TypedArray, ArrayBuffer, Iterable or Array-like object */ \
|
/* FIXME: Initialize from TypedArray, ArrayBuffer, Iterable or Array-like object */ \
|
||||||
TODO(); \
|
TODO(); \
|
||||||
} \
|
} \
|
||||||
/* FIXME: Use ToIndex() abstract operation */ \
|
auto array_length = vm.argument(0).to_index(global_object()); \
|
||||||
auto array_length_value = vm.argument(0); \
|
if (vm.exception()) { \
|
||||||
if (!array_length_value.is_integer() || array_length_value.as_i32() < 0) { \
|
/* Re-throw more specific RangeError */ \
|
||||||
vm.throw_exception<TypeError>(global_object(), ErrorType::ArrayInvalidLength); \
|
vm.clear_exception(); \
|
||||||
|
vm.throw_exception<RangeError>(global_object(), ErrorType::InvalidLength, "typed array"); \
|
||||||
return {}; \
|
return {}; \
|
||||||
} \
|
} \
|
||||||
auto* array = ClassName::create(global_object(), array_length_value.as_i32()); \
|
auto* array = ClassName::create(global_object(), array_length); \
|
||||||
return array; \
|
return array; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue