diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp index e0e6e70e2f..050a24a170 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp @@ -24,7 +24,7 @@ void ArrayIteratorPrototype::initialize(GlobalObject& global_object) auto& vm = this->vm(); Object::initialize(global_object); - define_old_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); + define_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 23.1.5.2.2 %ArrayIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Array Iterator"), Attribute::Configurable); @@ -36,9 +36,9 @@ ArrayIteratorPrototype::~ArrayIteratorPrototype() // 23.1.5.2.1 %ArrayIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next // FIXME: This seems to be CreateArrayIterator (https://tc39.es/ecma262/#sec-createarrayiterator) instead of %ArrayIteratorPrototype%.next. -JS_DEFINE_OLD_NATIVE_FUNCTION(ArrayIteratorPrototype::next) +JS_DEFINE_NATIVE_FUNCTION(ArrayIteratorPrototype::next) { - auto* iterator = TRY_OR_DISCARD(typed_this_value(global_object)); + auto* iterator = TRY(typed_this_value(global_object)); auto target_array = iterator->array(); if (target_array.is_undefined()) return create_iterator_result_object(global_object, js_undefined(), true); @@ -53,14 +53,12 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ArrayIteratorPrototype::next) if (array.is_typed_array()) { auto& typed_array = static_cast(array); - if (typed_array.viewed_array_buffer()->is_detached()) { - vm.throw_exception(global_object, ErrorType::DetachedArrayBuffer); - return {}; - } + if (typed_array.viewed_array_buffer()->is_detached()) + return vm.throw_completion(global_object, ErrorType::DetachedArrayBuffer); length = typed_array.array_length(); } else { - length = TRY_OR_DISCARD(length_of_array_like(global_object, array)); + length = TRY(length_of_array_like(global_object, array)); } if (index >= length) { @@ -72,7 +70,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ArrayIteratorPrototype::next) if (iteration_kind == Object::PropertyKind::Key) return create_iterator_result_object(global_object, Value(static_cast(index)), false); - auto value = TRY_OR_DISCARD(array.get(index)); + auto value = TRY(array.get(index)); if (iteration_kind == Object::PropertyKind::Value) return create_iterator_result_object(global_object, value, false); diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h index dde774fcbd..852c798c85 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h @@ -20,7 +20,7 @@ public: virtual ~ArrayIteratorPrototype() override; private: - JS_DECLARE_OLD_NATIVE_FUNCTION(next); + JS_DECLARE_NATIVE_FUNCTION(next); }; }