From d0e5fc45760c9a14046399a0e2cf2d8647d2b018 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 18 Sep 2021 19:32:51 +0300 Subject: [PATCH] LibJS: Convert supported_locales() to ThrowCompletionOr --- Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h | 2 +- .../Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp | 2 +- .../Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp | 2 +- .../Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp index a28ee4e9ba..7b4e0fd837 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp @@ -568,7 +568,7 @@ Vector best_fit_supported_locales(Vector const& requested_locale } // 9.2.10 SupportedLocales ( availableLocales, requestedLocales, options ), https://tc39.es/ecma402/#sec-supportedlocales -Array* supported_locales(GlobalObject& global_object, Vector const& requested_locales, Value options) +ThrowCompletionOr supported_locales(GlobalObject& global_object, Vector const& requested_locales, Value options) { auto& vm = global_object.vm(); @@ -578,7 +578,7 @@ Array* supported_locales(GlobalObject& global_object, Vector const& requ return {}; // 2. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). - auto matcher = TRY_OR_DISCARD(get_option(global_object, *options_object, vm.names.localeMatcher, Value::Type::String, { "lookup"sv, "best fit"sv }, "best fit"sv)); + auto matcher = TRY(get_option(global_object, *options_object, vm.names.localeMatcher, Value::Type::String, { "lookup"sv, "best fit"sv }, "best fit"sv)); Vector supported_locales; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h index bf837ed8d5..57622204e5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h @@ -44,7 +44,7 @@ String insert_unicode_extension_and_canonicalize(Unicode::LocaleID locale_id, Un LocaleResult resolve_locale(Vector const& requested_locales, LocaleOptions const& options, Vector const& relevant_extension_keys); Vector lookup_supported_locales(Vector const& requested_locales); Vector best_fit_supported_locales(Vector const& requested_locales); -Array* supported_locales(GlobalObject&, Vector const& requested_locales, Value options); +ThrowCompletionOr supported_locales(GlobalObject&, Vector const& requested_locales, Value options); Object* coerce_options_to_object(GlobalObject& global_object, Value options); ThrowCompletionOr get_option(GlobalObject& global_object, Object const& options, PropertyName const& property, Value::Type type, Vector const& values, Fallback fallback); Optional default_number_option(GlobalObject& global_object, Value value, int minimum, int maximum, Optional fallback); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp index 6c543ba582..376fdcaadd 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp @@ -131,7 +131,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesConstructor::supported_locales_of) return {}; // 3. Return ? SupportedLocales(availableLocales, requestedLocales, options). - return supported_locales(global_object, requested_locales, options); + return TRY_OR_DISCARD(supported_locales(global_object, requested_locales, options)); } } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp index 5764f6b80c..b3c13e0d7b 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp @@ -110,7 +110,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatConstructor::supported_locales_of) return {}; // 3. Return ? SupportedLocales(availableLocales, requestedLocales, options). - return supported_locales(global_object, requested_locales, options); + return TRY_OR_DISCARD(supported_locales(global_object, requested_locales, options)); } } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp index 2496a3739b..a425d01183 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp @@ -80,7 +80,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatConstructor::supported_locales_of) return {}; // 3. Return ? SupportedLocales(availableLocales, requestedLocales, options). - return supported_locales(global_object, requested_locales, options); + return TRY_OR_DISCARD(supported_locales(global_object, requested_locales, options)); } }