summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-10-23 03:54:57 +0300
committerAndreas Kling <kling@serenityos.org>2021-10-23 18:01:51 +0200
commita2fbf6a3d58e8a5d2849fc0b80c8bbcf480f272f (patch)
tree8d0f661ceb8a9135e55b5925dc75e95fc03f550e /Userland/Libraries
parente3181a7ded2e3729734150fcaf0232aa8e9c99f9 (diff)
downloadserenity-a2fbf6a3d58e8a5d2849fc0b80c8bbcf480f272f.zip
LibJS: Convert the MakeIndicesArray AO to ThrowCompletionOr
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
index 95967b43f8..b22821dd04 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
@@ -102,7 +102,7 @@ static Value get_match_indices_array(GlobalObject& global_object, Utf16View cons
}
// 1.1.4.1.5 MakeIndicesArray ( S , indices, groupNames, hasGroups ), https://tc39.es/proposal-regexp-match-indices/#sec-makeindicesarray
-static Value make_indices_array(GlobalObject& global_object, Utf16View const& string, Vector<Optional<Match>> const& indices, HashMap<FlyString, Match> const& group_names, bool has_groups)
+static ThrowCompletionOr<Value> make_indices_array(GlobalObject& global_object, Utf16View const& string, Vector<Optional<Match>> const& indices, HashMap<FlyString, Match> const& group_names, bool has_groups)
{
// Note: This implementation differs from the spec, but has the same behavior.
//
@@ -120,7 +120,7 @@ static Value make_indices_array(GlobalObject& global_object, Utf16View const& st
auto& vm = global_object.vm();
- auto* array = TRY_OR_DISCARD(Array::create(global_object, indices.size()));
+ auto* array = TRY(Array::create(global_object, indices.size()));
auto groups = has_groups ? Object::create(global_object, nullptr) : js_undefined();
@@ -131,16 +131,16 @@ static Value make_indices_array(GlobalObject& global_object, Utf16View const& st
if (match_indices.has_value())
match_indices_array = get_match_indices_array(global_object, string, *match_indices);
- TRY_OR_DISCARD(array->create_data_property(i, match_indices_array));
+ TRY(array->create_data_property(i, match_indices_array));
}
for (auto const& entry : group_names) {
auto match_indices_array = get_match_indices_array(global_object, string, entry.value);
- TRY_OR_DISCARD(groups.as_object().create_data_property(entry.key, match_indices_array));
+ TRY(groups.as_object().create_data_property(entry.key, match_indices_array));
}
- TRY_OR_DISCARD(array->create_data_property(vm.names.groups, groups));
+ TRY(array->create_data_property(vm.names.groups, groups));
return array;
}
@@ -234,7 +234,7 @@ static Value regexp_builtin_exec(GlobalObject& global_object, RegExpObject& rege
MUST(array->create_data_property_or_throw(vm.names.groups, groups));
if (has_indices) {
- auto indices_array = make_indices_array(global_object, string_view, indices, group_names, has_groups);
+ auto indices_array = TRY_OR_DISCARD(make_indices_array(global_object, string_view, indices, group_names, has_groups));
TRY_OR_DISCARD(array->create_data_property(vm.names.indices, indices_array));
}