diff --git a/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp index 687cb81b9d3..d9dc29c6068 100644 --- a/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp @@ -64,7 +64,7 @@ ThrowCompletionOr> DisplayNamesConstructor::construct(FunctionOb return vm.throw_completion(ErrorType::IsUndefined, "options"sv); // 5. Set options to ? GetOptionsObject(options). - auto* options = TRY(Temporal::get_options_object(vm, options_value)); + auto options = TRY(Temporal::get_options_object(vm, options_value)); // 6. Let opt be a new Record. LocaleOptions opt {}; diff --git a/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp index 0bed08fd2bc..09732181758 100644 --- a/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp @@ -59,7 +59,7 @@ ThrowCompletionOr> DurationFormatConstructor::construct(Function auto requested_locales = TRY(canonicalize_locale_list(vm, locales)); // 4. Let options be ? GetOptionsObject(options). - auto* options = TRY(Temporal::get_options_object(vm, options_value)); + auto options = TRY(Temporal::get_options_object(vm, options_value)); // 5. Let matcher be ? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit"). auto matcher = TRY(get_option(vm, *options, vm.names.localeMatcher, OptionType::String, { "lookup"sv, "best fit"sv }, "best fit"sv)); diff --git a/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp index a6d7b63695c..57aa811c510 100644 --- a/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp @@ -59,7 +59,7 @@ ThrowCompletionOr> ListFormatConstructor::construct(FunctionObje auto requested_locales = TRY(canonicalize_locale_list(vm, locale_value)); // 4. Set options to ? GetOptionsObject(options). - auto* options = TRY(Temporal::get_options_object(vm, options_value)); + auto options = TRY(Temporal::get_options_object(vm, options_value)); // 5. Let opt be a new Record. LocaleOptions opt {}; diff --git a/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp b/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp index f380c2452b4..7215bb6a239 100644 --- a/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp @@ -60,7 +60,7 @@ ThrowCompletionOr> SegmenterConstructor::construct(FunctionObjec auto requested_locales = TRY(canonicalize_locale_list(vm, locales)); // 5. Set options to ? GetOptionsObject(options). - auto* options = TRY(Temporal::get_options_object(vm, options_value)); + auto options = TRY(Temporal::get_options_object(vm, options_value)); // 6. Let opt be a new Record. LocaleOptions opt {}; diff --git a/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 462bf1abdd5..5ceb5e158af 100644 --- a/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -13,20 +13,20 @@ namespace JS::Temporal { // 14.4.1.1 GetOptionsObject ( options ), https://tc39.es/proposal-temporal/#sec-getoptionsobject -ThrowCompletionOr get_options_object(VM& vm, Value options) +ThrowCompletionOr> get_options_object(VM& vm, Value options) { auto& realm = *vm.current_realm(); // 1. If options is undefined, then if (options.is_undefined()) { // a. Return OrdinaryObjectCreate(null). - return Object::create(realm, nullptr).ptr(); + return Object::create(realm, nullptr); } // 2. If options is an Object, then if (options.is_object()) { // a. Return options. - return &options.as_object(); + return options.as_object(); } // 3. Throw a TypeError exception. diff --git a/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h b/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h index fbd42458fa9..38c40c9995f 100644 --- a/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h +++ b/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include #include #include @@ -39,7 +40,7 @@ enum class OptionType { struct DefaultRequired { }; using OptionDefault = Variant; -ThrowCompletionOr get_options_object(VM&, Value options); +ThrowCompletionOr> get_options_object(VM&, Value options); ThrowCompletionOr get_option(VM&, Object const& options, PropertyKey const& property, OptionType type, ReadonlySpan values, OptionDefault const&); template diff --git a/Libraries/LibJS/Runtime/Uint8Array.cpp b/Libraries/LibJS/Runtime/Uint8Array.cpp index c2f85387654..89dffdcd322 100644 --- a/Libraries/LibJS/Runtime/Uint8Array.cpp +++ b/Libraries/LibJS/Runtime/Uint8Array.cpp @@ -87,7 +87,7 @@ JS_DEFINE_NATIVE_FUNCTION(Uint8ArrayPrototypeHelpers::to_base64) auto typed_array = TRY(validate_uint8_array(vm)); // 3. Let opts be ? GetOptionsObject(options). - auto* options = TRY(Temporal::get_options_object(vm, options_value)); + auto options = TRY(Temporal::get_options_object(vm, options_value)); // 4. Let alphabet be ? Get(opts, "alphabet"). // 5. If alphabet is undefined, set alphabet to "base64". @@ -159,7 +159,7 @@ JS_DEFINE_NATIVE_FUNCTION(Uint8ArrayConstructorHelpers::from_base64) return vm.throw_completion(ErrorType::NotAString, string_value); // 2. Let opts be ? GetOptionsObject(options). - auto* options = TRY(Temporal::get_options_object(vm, options_value)); + auto options = TRY(Temporal::get_options_object(vm, options_value)); // 3. Let alphabet be ? Get(opts, "alphabet"). // 4. If alphabet is undefined, set alphabet to "base64". @@ -214,7 +214,7 @@ JS_DEFINE_NATIVE_FUNCTION(Uint8ArrayPrototypeHelpers::set_from_base64) return vm.throw_completion(ErrorType::NotAString, string_value); // 4. Let opts be ? GetOptionsObject(options). - auto* options = TRY(Temporal::get_options_object(vm, options_value)); + auto options = TRY(Temporal::get_options_object(vm, options_value)); // 5. Let alphabet be ? Get(opts, "alphabet"). // 6. If alphabet is undefined, set alphabet to "base64".