From a2fbf6a3d58e8a5d2849fc0b80c8bbcf480f272f Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 23 Oct 2021 03:54:57 +0300 Subject: [PATCH] LibJS: Convert the MakeIndicesArray AO to ThrowCompletionOr --- Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp | 12 ++++++------ 1 file 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> const& indices, HashMap const& group_names, bool has_groups) +static ThrowCompletionOr make_indices_array(GlobalObject& global_object, Utf16View const& string, Vector> const& indices, HashMap 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)); }