LibJS: Mark IteratorHelper::create as infallible

This is just allocating an IteratorHelper. There is no way for this to
throw an exception.
This commit is contained in:
Timothy Flynn
2025-12-02 12:32:57 -05:00
committed by Andreas Kling
parent e011f8d6b1
commit 6976ff389e
Notes: github-actions[bot] 2025-12-03 11:10:01 +00:00
3 changed files with 7 additions and 7 deletions

View File

@@ -13,7 +13,7 @@ namespace JS {
GC_DEFINE_ALLOCATOR(IteratorHelper);
ThrowCompletionOr<GC::Ref<IteratorHelper>> IteratorHelper::create(Realm& realm, ReadonlySpan<GC::Ref<IteratorRecord>> underlying_iterators, GC::Ref<Closure> closure, GC::Ptr<AbruptClosure> abrupt_closure)
GC::Ref<IteratorHelper> IteratorHelper::create(Realm& realm, ReadonlySpan<GC::Ref<IteratorRecord>> underlying_iterators, GC::Ref<Closure> closure, GC::Ptr<AbruptClosure> abrupt_closure)
{
return realm.create<IteratorHelper>(realm, realm.intrinsics().iterator_helper_prototype(), underlying_iterators, closure, abrupt_closure);
}

View File

@@ -22,7 +22,7 @@ public:
using Closure = GC::Function<ThrowCompletionOr<Value>(VM&, IteratorHelper&)>;
using AbruptClosure = GC::Function<ThrowCompletionOr<Value>(VM&, IteratorHelper&, Completion const&)>;
static ThrowCompletionOr<GC::Ref<IteratorHelper>> create(Realm&, ReadonlySpan<GC::Ref<IteratorRecord>>, GC::Ref<Closure>, GC::Ptr<AbruptClosure> = {});
static GC::Ref<IteratorHelper> create(Realm&, ReadonlySpan<GC::Ref<IteratorRecord>>, GC::Ref<Closure>, GC::Ptr<AbruptClosure> = {});
ReadonlySpan<GC::Ref<IteratorRecord>> underlying_iterators() const { return m_underlying_iterators; }

View File

@@ -149,7 +149,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::drop)
// 11. Let result be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
// 12. Set result.[[UnderlyingIterators]] to « iterated ».
auto result = TRY(IteratorHelper::create(realm, { { iterated } }, closure));
auto result = IteratorHelper::create(realm, { { iterated } }, closure);
// 11. Return result.
return result;
@@ -264,7 +264,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::filter)
// 7. Let result be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
// 8. Set result.[[UnderlyingIterators]] to « iterated ».
auto result = TRY(IteratorHelper::create(realm, { { iterated } }, closure));
auto result = IteratorHelper::create(realm, { { iterated } }, closure);
// 9. Return result.
return result;
@@ -462,7 +462,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::flat_map)
// 8. Let result be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
// 9. Set result.[[UnderlyingIterators]] to « iterated ».
auto result = TRY(IteratorHelper::create(realm, { { iterated } }, closure, move(abrupt_closure)));
auto result = IteratorHelper::create(realm, { { iterated } }, closure, move(abrupt_closure));
// 9. Return result.
return result;
@@ -569,7 +569,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::map)
// 7. Let result be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
// 8. Set result.[[UnderlyingIterators]] to « iterated ».
auto result = TRY(IteratorHelper::create(realm, { { iterated } }, closure));
auto result = IteratorHelper::create(realm, { { iterated } }, closure);
// 9. Return result.
return result;
@@ -773,7 +773,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::take)
// 11. Let result be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
// 12. Set result.[[UnderlyingIterators]] to « iterated ».
auto result = TRY(IteratorHelper::create(realm, { { iterated } }, closure));
auto result = IteratorHelper::create(realm, { { iterated } }, closure);
// 13. Return result.
return result;