diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 15b0e9523f..de88ab719f 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -1300,9 +1300,7 @@ ThrowCompletionOr ClassExpression::class_definition_evaluation(Interprete if (initializer) field_value = TRY(interpreter.vm().call(*initializer, class_constructor_value)); - class_constructor->create_data_property_or_throw(property_key, field_value); - if (auto* exception = interpreter.exception()) - return throw_completion(exception->value()); + TRY(class_constructor->create_data_property_or_throw(property_key, field_value)); } else { class_constructor->add_field(property_key, initializer); } diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 59ffbeb424..99f9c718ac 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -154,7 +154,7 @@ void IteratorToArray::execute_impl(Bytecode::Interpreter& interpreter) const if (vm.exception()) return; - array->create_data_property_or_throw(index, value); + MUST(array->create_data_property_or_throw(index, value)); index++; } } diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index 4086024a2d..1fdd7730c4 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -694,8 +694,7 @@ Object* create_unmapped_arguments_object(GlobalObject& global_object, Spancreate_data_property_or_throw(index, value); - VERIFY(!vm.exception()); + MUST(object->create_data_property_or_throw(index, value)); // c. Set index to index + 1. } @@ -742,8 +741,7 @@ Object* create_mapped_arguments_object(GlobalObject& global_object, FunctionObje auto value = arguments[index]; // b. Perform ! CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), val). - object->create_data_property_or_throw(index, value); - VERIFY(!vm.exception()); + MUST(object->create_data_property_or_throw(index, value)); // c. Set index to index + 1. } diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp index a62a6934c7..d26971a632 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.cpp +++ b/Userland/Libraries/LibJS/Runtime/Array.cpp @@ -40,7 +40,8 @@ Array* Array::create_from(GlobalObject& global_object, Vector const& elem // 4. For each element e of elements, do for (u32 n = 0; n < elements.size(); ++n) { // a. Perform ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), e). - array->create_data_property_or_throw(n, elements[n]); + MUST(array->create_data_property_or_throw(n, elements[n])); + // b. Set n to n + 1. } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index 80f13ed41d..0ac4ab32a7 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -65,7 +65,7 @@ Value ArrayConstructor::construct(FunctionObject& new_target) auto* array = Array::create(global_object(), 0, proto); size_t int_length; if (!length.is_number()) { - array->create_data_property_or_throw(0, length); + MUST(array->create_data_property_or_throw(0, length)); int_length = 1; } else { int_length = length.to_u32(global_object()); @@ -83,7 +83,7 @@ Value ArrayConstructor::construct(FunctionObject& new_target) return {}; for (size_t k = 0; k < vm.argument_count(); ++k) - array->create_data_property_or_throw(k, vm.argument(k)); + MUST(array->create_data_property_or_throw(k, vm.argument(k))); return array; } @@ -155,8 +155,8 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from) mapped_value = next_value; } - array_object.create_data_property_or_throw(k, mapped_value); - if (vm.exception()) { + auto result_or_error = array_object.create_data_property_or_throw(k, mapped_value); + if (result_or_error.is_error()) { iterator_close(*iterator); return {}; } @@ -191,7 +191,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from) mapped_value = TRY_OR_DISCARD(vm.call(*map_fn, this_arg, k_value, Value(k))); else mapped_value = k_value; - array_object.create_data_property_or_throw(k, mapped_value); + TRY_OR_DISCARD(array_object.create_data_property_or_throw(k, mapped_value)); } TRY_OR_DISCARD(array_object.set(vm.names.length, Value(length), Object::ShouldThrowExceptions::Yes)); @@ -223,11 +223,8 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::of) return {}; } auto& array_object = array.as_object(); - for (size_t k = 0; k < vm.argument_count(); ++k) { - array_object.create_data_property_or_throw(k, vm.argument(k)); - if (vm.exception()) - return {}; - } + for (size_t k = 0; k < vm.argument_count(); ++k) + TRY_OR_DISCARD(array_object.create_data_property_or_throw(k, vm.argument(k))); TRY_OR_DISCARD(array_object.set(vm.names.length, Value(vm.argument_count()), Object::ShouldThrowExceptions::Yes)); return array; } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index c856d3fe55..acca92a240 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -82,18 +82,18 @@ void ArrayPrototype::initialize(GlobalObject& global_object) // 23.1.3.34 Array.prototype [ @@unscopables ], https://tc39.es/ecma262/#sec-array.prototype-@@unscopables // With proposal, https://tc39.es/proposal-array-find-from-last/index.html#sec-array.prototype-@@unscopables auto* unscopable_list = Object::create(global_object, nullptr); - unscopable_list->create_data_property_or_throw(vm.names.copyWithin, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.entries, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.fill, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.find, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.findIndex, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.findLast, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.findLastIndex, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.flat, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.flatMap, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.includes, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.keys, Value(true)); - unscopable_list->create_data_property_or_throw(vm.names.values, Value(true)); + MUST(unscopable_list->create_data_property_or_throw(vm.names.copyWithin, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.entries, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.fill, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.find, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.findIndex, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.findLast, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.findLastIndex, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.flat, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.flatMap, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.includes, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.keys, Value(true))); + MUST(unscopable_list->create_data_property_or_throw(vm.names.values, Value(true))); define_direct_property(*vm.well_known_symbol_unscopables(), unscopable_list, Attribute::Configurable); } @@ -205,7 +205,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::filter) // iii. If selected is true, then if (selected) { // 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(𝔽(to)), kValue). - array->create_data_property_or_throw(to, k_value); + TRY_OR_DISCARD(array->create_data_property_or_throw(to, k_value)); // 2. Set to to to + 1. ++to; @@ -313,9 +313,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::map) auto mapped_value = TRY_OR_DISCARD(vm.call(callback_function.as_function(), this_arg, k_value, Value(k), object)); // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). - array->create_data_property_or_throw(property_name, mapped_value); - if (vm.exception()) - return {}; + TRY_OR_DISCARD(array->create_data_property_or_throw(property_name, mapped_value)); } // d. Set k to k + 1. @@ -581,8 +579,8 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::concat) if (k_value_or_error.is_error()) return; auto k_value = k_value_or_error.release_value(); - new_array->create_data_property_or_throw(n, k_value); - if (vm.exception()) + auto result_or_error = new_array->create_data_property_or_throw(n, k_value); + if (result_or_error.is_error()) return; } ++n; @@ -593,8 +591,8 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::concat) vm.throw_exception(global_object, ErrorType::ArrayMaxSize); return; } - new_array->create_data_property_or_throw(n, arg); - if (vm.exception()) + auto result_or_error = new_array->create_data_property_or_throw(n, arg); + if (result_or_error.is_error()) return; ++n; } @@ -672,9 +670,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::slice) if (present) { auto value = TRY_OR_DISCARD(this_object->get(k)); - new_array->create_data_property_or_throw(index, value); - if (vm.exception()) - return {}; + TRY_OR_DISCARD(new_array->create_data_property_or_throw(index, value)); } ++k; @@ -1594,9 +1590,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice) if (from_present) { auto from_value = TRY_OR_DISCARD(this_object->get(from)); - removed_elements->create_data_property_or_throw(i, from_value); - if (vm.exception()) - return {}; + TRY_OR_DISCARD(removed_elements->create_data_property_or_throw(i, from_value)); } } @@ -1767,9 +1761,7 @@ static size_t flatten_into_array(GlobalObject& global_object, Object& new_array, return {}; } - new_array.create_data_property_or_throw(target_index, value); - if (vm.exception()) - return {}; + TRY_OR_DISCARD(new_array.create_data_property_or_throw(target_index, value)); ++target_index; } diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 88b0d80c11..0aa018b9b3 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -442,7 +442,7 @@ void ECMAScriptFunctionObject::InstanceField::define_field(VM& vm, Object& recei return; init_value = init_value_or_error.release_value(); } - receiver.create_data_property_or_throw(name, init_value); + (void)receiver.create_data_property_or_throw(name, init_value); } } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index cdcac329a4..5fd699a33e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -101,10 +101,10 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options) // b. Let v be the value of displayNames's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). - options->create_data_property_or_throw(vm.names.locale, js_string(vm, display_names->locale())); - options->create_data_property_or_throw(vm.names.style, js_string(vm, display_names->style_string())); - options->create_data_property_or_throw(vm.names.type, js_string(vm, display_names->type_string())); - options->create_data_property_or_throw(vm.names.fallback, js_string(vm, display_names->fallback_string())); + MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, display_names->locale()))); + MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, display_names->style_string()))); + MUST(options->create_data_property_or_throw(vm.names.type, js_string(vm, display_names->type_string()))); + MUST(options->create_data_property_or_throw(vm.names.fallback, js_string(vm, display_names->fallback_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp index 0d18ae9608..4995e51adc 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp @@ -248,13 +248,13 @@ Array* format_list_to_parts(GlobalObject& global_object, ListFormat const& list_ auto* object = Object::create(global_object, global_object.object_prototype()); // b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]). - object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)); + MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type))); // c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]). - object->create_data_property_or_throw(vm.names.value, js_string(vm, part.value)); + MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, part.value))); // d. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O). - result->create_data_property_or_throw(n, object); + MUST(result->create_data_property_or_throw(n, object)); // e. Increment n by 1. ++n; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp index 2ef8359e2b..bdb64ae06f 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp @@ -87,9 +87,9 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options) // b. Let v be the value of lf's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. // d. Perform ! CreateDataPropertyOrThrow(options, p, v). - options->create_data_property_or_throw(vm.names.locale, js_string(vm, list_format->locale())); - options->create_data_property_or_throw(vm.names.type, js_string(vm, list_format->type_string())); - options->create_data_property_or_throw(vm.names.style, js_string(vm, list_format->style_string())); + MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, list_format->locale()))); + MUST(options->create_data_property_or_throw(vm.names.type, js_string(vm, list_format->type_string()))); + MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, list_format->style_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp index 40f7d7e4f9..8c4983625a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp @@ -49,33 +49,33 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options) // b. Let v be the value of nf's internal slot whose name is the Internal Slot value of the current row. // c. If v is not undefined, then // i. Perform ! CreateDataPropertyOrThrow(options, p, v). - options->create_data_property_or_throw(vm.names.locale, js_string(vm, number_format->locale())); - options->create_data_property_or_throw(vm.names.numberingSystem, js_string(vm, number_format->numbering_system())); - options->create_data_property_or_throw(vm.names.style, js_string(vm, number_format->style_string())); + MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, number_format->locale()))); + MUST(options->create_data_property_or_throw(vm.names.numberingSystem, js_string(vm, number_format->numbering_system()))); + MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, number_format->style_string()))); if (number_format->has_currency()) - options->create_data_property_or_throw(vm.names.currency, js_string(vm, number_format->currency())); + MUST(options->create_data_property_or_throw(vm.names.currency, js_string(vm, number_format->currency()))); if (number_format->has_currency_display()) - options->create_data_property_or_throw(vm.names.currencyDisplay, js_string(vm, number_format->currency_display_string())); + MUST(options->create_data_property_or_throw(vm.names.currencyDisplay, js_string(vm, number_format->currency_display_string()))); if (number_format->has_currency_sign()) - options->create_data_property_or_throw(vm.names.currencySign, js_string(vm, number_format->currency_sign_string())); + MUST(options->create_data_property_or_throw(vm.names.currencySign, js_string(vm, number_format->currency_sign_string()))); if (number_format->has_unit()) - options->create_data_property_or_throw(vm.names.unit, js_string(vm, number_format->unit())); + MUST(options->create_data_property_or_throw(vm.names.unit, js_string(vm, number_format->unit()))); if (number_format->has_unit_display()) - options->create_data_property_or_throw(vm.names.unitDisplay, js_string(vm, number_format->unit_display_string())); - options->create_data_property_or_throw(vm.names.minimumIntegerDigits, Value(number_format->min_integer_digits())); + MUST(options->create_data_property_or_throw(vm.names.unitDisplay, js_string(vm, number_format->unit_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.minimumIntegerDigits, Value(number_format->min_integer_digits()))); if (number_format->has_min_fraction_digits()) - options->create_data_property_or_throw(vm.names.minimumFractionDigits, Value(number_format->min_fraction_digits())); + MUST(options->create_data_property_or_throw(vm.names.minimumFractionDigits, Value(number_format->min_fraction_digits()))); if (number_format->has_max_fraction_digits()) - options->create_data_property_or_throw(vm.names.maximumFractionDigits, Value(number_format->max_fraction_digits())); + MUST(options->create_data_property_or_throw(vm.names.maximumFractionDigits, Value(number_format->max_fraction_digits()))); if (number_format->has_min_significant_digits()) - options->create_data_property_or_throw(vm.names.minimumSignificantDigits, Value(number_format->min_significant_digits())); + MUST(options->create_data_property_or_throw(vm.names.minimumSignificantDigits, Value(number_format->min_significant_digits()))); if (number_format->has_max_significant_digits()) - options->create_data_property_or_throw(vm.names.maximumSignificantDigits, Value(number_format->max_significant_digits())); - options->create_data_property_or_throw(vm.names.useGrouping, Value(number_format->use_grouping())); - options->create_data_property_or_throw(vm.names.notation, js_string(vm, number_format->notation_string())); + MUST(options->create_data_property_or_throw(vm.names.maximumSignificantDigits, Value(number_format->max_significant_digits()))); + MUST(options->create_data_property_or_throw(vm.names.useGrouping, Value(number_format->use_grouping()))); + MUST(options->create_data_property_or_throw(vm.names.notation, js_string(vm, number_format->notation_string()))); if (number_format->has_compact_display()) - options->create_data_property_or_throw(vm.names.compactDisplay, js_string(vm, number_format->compact_display_string())); - options->create_data_property_or_throw(vm.names.signDisplay, js_string(vm, number_format->sign_display_string())); + MUST(options->create_data_property_or_throw(vm.names.compactDisplay, js_string(vm, number_format->compact_display_string()))); + MUST(options->create_data_property_or_throw(vm.names.signDisplay, js_string(vm, number_format->sign_display_string()))); // 5. Return options. return options; diff --git a/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp b/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp index e72c94966c..6dbe309499 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp @@ -147,8 +147,8 @@ Object* create_iterator_result_object(GlobalObject& global_object, Value value, { auto& vm = global_object.vm(); auto* object = Object::create(global_object, global_object.object_prototype()); - object->create_data_property_or_throw(vm.names.value, value); - object->create_data_property_or_throw(vm.names.done, Value(done)); + MUST(object->create_data_property_or_throw(vm.names.value, value)); + MUST(object->create_data_property_or_throw(vm.names.done, Value(done))); return object; } diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index 7473125bdc..97bc105138 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -111,7 +111,7 @@ String JSONObject::stringify_impl(GlobalObject& global_object, Value value, Valu } auto* wrapper = Object::create(global_object, global_object.object_prototype()); - wrapper->create_data_property_or_throw(String::empty(), value); + MUST(wrapper->create_data_property_or_throw(String::empty(), value)); auto result = serialize_json_property(global_object, state, String::empty(), wrapper); if (vm.exception()) return {}; @@ -408,7 +408,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse) if (reviver.is_function()) { auto* root = Object::create(global_object, global_object.object_prototype()); auto root_name = String::empty(); - root->create_data_property_or_throw(root_name, unfiltered); + MUST(root->create_data_property_or_throw(root_name, unfiltered)); auto result = internalize_json_property(global_object, root, root_name, reviver.as_function()); if (vm.exception()) return {}; diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index c2e67a2904..acfe9e0716 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -159,7 +159,7 @@ ThrowCompletionOr Object::create_method_property(PropertyName const& prope } // 7.3.7 CreateDataPropertyOrThrow ( O, P, V ), https://tc39.es/ecma262/#sec-createdatapropertyorthrow -bool Object::create_data_property_or_throw(PropertyName const& property_name, Value value) +ThrowCompletionOr Object::create_data_property_or_throw(PropertyName const& property_name, Value value) { VERIFY(!value.is_empty()); auto& vm = this->vm(); @@ -170,13 +170,12 @@ bool Object::create_data_property_or_throw(PropertyName const& property_name, Va VERIFY(property_name.is_valid()); // 3. Let success be ? CreateDataProperty(O, P, V). - auto success = TRY_OR_DISCARD(create_data_property(property_name, value)); + auto success = TRY(create_data_property(property_name, value)); // 4. If success is false, throw a TypeError exception. if (!success) { // FIXME: Improve/contextualize error message - vm.throw_exception(global_object(), ErrorType::ObjectDefineOwnPropertyReturnedFalse); - return {}; + return vm.throw_completion(global_object(), ErrorType::ObjectDefineOwnPropertyReturnedFalse); } // 5. Return success. @@ -479,9 +478,7 @@ ThrowCompletionOr Object::copy_data_properties(Value source, HashTable< if (desc.has_value() && desc->attributes().is_enumerable()) { auto prop_value = TRY(from_object->get(next_key)); - create_data_property_or_throw(next_key, prop_value); - if (auto* thrown_exception = vm().exception()) - return JS::throw_completion(thrown_exception->value()); + TRY(create_data_property_or_throw(next_key, prop_value)); } } return this; diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index eecdcf0b35..bd50043884 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -79,7 +79,7 @@ public: ThrowCompletionOr set(PropertyName const&, Value, ShouldThrowExceptions); ThrowCompletionOr create_data_property(PropertyName const&, Value); ThrowCompletionOr create_method_property(PropertyName const&, Value); - bool create_data_property_or_throw(PropertyName const&, Value); + ThrowCompletionOr create_data_property_or_throw(PropertyName const&, Value); bool create_non_enumerable_data_property_or_throw(PropertyName const&, Value); bool define_property_or_throw(PropertyName const&, PropertyDescriptor const&); bool delete_property_or_throw(PropertyName const&); diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index b038fb9a6e..94326e9f29 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -256,8 +256,8 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries) auto property_key = key.to_property_key(global_object); if (vm.exception()) return IterationDecision::Break; - object->create_data_property_or_throw(property_key, value); - if (vm.exception()) + auto result_or_error = object->create_data_property_or_throw(property_key, value); + if (result_or_error.is_error()) return IterationDecision::Break; return IterationDecision::Continue; }); @@ -321,7 +321,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_descriptors) // c. If descriptor is not undefined, perform ! CreateDataPropertyOrThrow(descriptors, key, descriptor). if (!descriptor.is_undefined()) - descriptors->create_data_property_or_throw(property_name, descriptor); + MUST(descriptors->create_data_property_or_throw(property_name, descriptor)); } // 5. Return descriptors. diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp index 83dd7cd8c2..e98278f2fa 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp @@ -89,8 +89,8 @@ Value PromiseAllSettledResolveElementFunction::resolve_element() auto& global_object = this->global_object(); auto* object = Object::create(global_object, global_object.object_prototype()); - object->create_data_property_or_throw(vm.names.status, js_string(vm, "fulfilled"sv)); - object->create_data_property_or_throw(vm.names.value, vm.argument(0)); + MUST(object->create_data_property_or_throw(vm.names.status, js_string(vm, "fulfilled"sv))); + MUST(object->create_data_property_or_throw(vm.names.value, vm.argument(0))); m_values.values()[m_index] = object; @@ -118,8 +118,8 @@ Value PromiseAllSettledRejectElementFunction::resolve_element() auto& global_object = this->global_object(); auto* object = Object::create(global_object, global_object.object_prototype()); - object->create_data_property_or_throw(vm.names.status, js_string(vm, "rejected"sv)); - object->create_data_property_or_throw(vm.names.reason, vm.argument(0)); + MUST(object->create_data_property_or_throw(vm.names.status, js_string(vm, "rejected"sv))); + MUST(object->create_data_property_or_throw(vm.names.reason, vm.argument(0))); m_values.values()[m_index] = object; diff --git a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp index 71a304166a..13968ca6bc 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp @@ -60,17 +60,17 @@ Value from_property_descriptor(GlobalObject& global_object, Optionalvalue.has_value()) - object->create_data_property_or_throw(vm.names.value, *property_descriptor->value); + MUST(object->create_data_property_or_throw(vm.names.value, *property_descriptor->value)); if (property_descriptor->writable.has_value()) - object->create_data_property_or_throw(vm.names.writable, Value(*property_descriptor->writable)); + MUST(object->create_data_property_or_throw(vm.names.writable, Value(*property_descriptor->writable))); if (property_descriptor->get.has_value()) - object->create_data_property_or_throw(vm.names.get, *property_descriptor->get ? Value(*property_descriptor->get) : js_undefined()); + MUST(object->create_data_property_or_throw(vm.names.get, *property_descriptor->get ? Value(*property_descriptor->get) : js_undefined())); if (property_descriptor->set.has_value()) - object->create_data_property_or_throw(vm.names.set, *property_descriptor->set ? Value(*property_descriptor->set) : js_undefined()); + MUST(object->create_data_property_or_throw(vm.names.set, *property_descriptor->set ? Value(*property_descriptor->set) : js_undefined())); if (property_descriptor->enumerable.has_value()) - object->create_data_property_or_throw(vm.names.enumerable, Value(*property_descriptor->enumerable)); + MUST(object->create_data_property_or_throw(vm.names.enumerable, Value(*property_descriptor->enumerable))); if (property_descriptor->configurable.has_value()) - object->create_data_property_or_throw(vm.names.configurable, Value(*property_descriptor->configurable)); + MUST(object->create_data_property_or_throw(vm.names.configurable, Value(*property_descriptor->configurable))); return object; } diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp index 5b77fcc528..2193ed689c 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -84,8 +84,8 @@ JS_DEFINE_NATIVE_FUNCTION(ProxyConstructor::revocable) revoker->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable); auto* result = Object::create(global_object, global_object.object_prototype()); - result->create_data_property_or_throw(vm.names.proxy, proxy); - result->create_data_property_or_throw(vm.names.revoke, revoker); + MUST(result->create_data_property_or_throw(vm.names.proxy, proxy)); + MUST(result->create_data_property_or_throw(vm.names.revoke, revoker)); return result; } diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp index 9e774befc3..a2f4d9c6e2 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp @@ -237,26 +237,26 @@ static Value regexp_builtin_exec(GlobalObject& global_object, RegExpObject& rege capture_value = js_string(vm, capture.view.u16_view()); indices.append(Match::create(capture)); } - array->create_data_property_or_throw(i + 1, capture_value); + MUST(array->create_data_property_or_throw(i + 1, capture_value)); if (capture.capture_group_name.has_value()) { auto group_name = capture.capture_group_name.release_value(); - groups_object->create_data_property_or_throw(group_name, js_string(vm, capture.view.u16_view())); + MUST(groups_object->create_data_property_or_throw(group_name, js_string(vm, capture.view.u16_view()))); group_names.set(move(group_name), Match::create(capture)); } } Value groups = has_groups ? groups_object : js_undefined(); - array->create_data_property_or_throw(vm.names.groups, groups); + 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); TRY_OR_DISCARD(array->create_data_property(vm.names.indices, indices_array)); } - array->create_data_property_or_throw(vm.names.index, Value(match_index)); - array->create_data_property_or_throw(vm.names.input, js_string(vm, move(string))); - array->create_data_property_or_throw(0, js_string(vm, match.view.u16_view())); + MUST(array->create_data_property_or_throw(vm.names.index, Value(match_index))); + MUST(array->create_data_property_or_throw(vm.names.input, js_string(vm, move(string)))); + MUST(array->create_data_property_or_throw(0, js_string(vm, match.view.u16_view()))); return array; } @@ -448,9 +448,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match) if (vm.exception()) return {}; - array->create_data_property_or_throw(n, js_string(vm, match_str)); - if (vm.exception()) - return {}; + TRY_OR_DISCARD(array->create_data_property_or_throw(n, js_string(vm, match_str))); if (match_str.is_empty()) TRY_OR_DISCARD(increment_last_index(global_object, *regexp_object, string.view(), unicode)); @@ -724,7 +722,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split) if (!result.is_null()) return array; - array->create_data_property_or_throw(0, js_string(vm, move(string))); + MUST(array->create_data_property_or_throw(0, js_string(vm, move(string)))); return array; } @@ -753,7 +751,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split) } auto substring = string_view.substring_view(last_match_end, next_search_from - last_match_end); - array->create_data_property_or_throw(array_length, js_string(vm, move(substring))); + MUST(array->create_data_property_or_throw(array_length, js_string(vm, move(substring)))); if (++array_length == limit) return array; @@ -769,7 +767,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split) for (size_t i = 1; i <= number_of_captures; ++i) { auto next_capture = TRY_OR_DISCARD(result_object->get(i)); - array->create_data_property_or_throw(array_length, next_capture); + MUST(array->create_data_property_or_throw(array_length, next_capture)); if (++array_length == limit) return array; } @@ -779,7 +777,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split) } auto substring = string_view.substring_view(last_match_end); - array->create_data_property_or_throw(array_length, js_string(vm, move(substring))); + MUST(array->create_data_property_or_throw(array_length, js_string(vm, move(substring)))); return array; } diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index ec39baf1cd..9054837e47 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -740,13 +740,13 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::split) auto separator_length = separator.length_in_code_units(); if (separator_argument.is_undefined()) { - array->create_data_property_or_throw(0, js_string(vm, move(string))); + MUST(array->create_data_property_or_throw(0, js_string(vm, move(string)))); return array; } if (string_length == 0) { if (separator_length > 0) - array->create_data_property_or_throw(0, js_string(vm, move(string))); + MUST(array->create_data_property_or_throw(0, js_string(vm, move(string)))); return array; } @@ -760,7 +760,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::split) } auto segment = string.substring_view(start, position - start); - array->create_data_property_or_throw(array_length, js_string(vm, segment)); + MUST(array->create_data_property_or_throw(array_length, js_string(vm, segment))); ++array_length; if (array_length == limit) return array; @@ -769,7 +769,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::split) } auto rest = string.substring_view(start); - array->create_data_property_or_throw(array_length, js_string(vm, rest)); + MUST(array->create_data_property_or_throw(array_length, js_string(vm, rest))); return array; } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 83f02c89ad..41c4bcae24 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -1082,7 +1082,7 @@ ThrowCompletionOr prepare_temporal_fields(GlobalObject& global_object, } // d. Perform ! CreateDataPropertyOrThrow(result, property, value). - result->create_data_property_or_throw(property, value); + MUST(result->create_data_property_or_throw(property, value)); } // 4. Return result. diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index d02c00a07d..31073ad7ff 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -957,7 +957,7 @@ ThrowCompletionOr default_merge_fields(GlobalObject& global_object, Obj // ii. If propValue is not undefined, then if (!prop_value.is_undefined()) { // 1. Perform ! CreateDataPropertyOrThrow(merged, nextKey, propValue). - merged->create_data_property_or_throw(property_name, prop_value); + MUST(merged->create_data_property_or_throw(property_name, prop_value)); } } } @@ -980,7 +980,7 @@ ThrowCompletionOr default_merge_fields(GlobalObject& global_object, Obj // b. If propValue is not undefined, then if (!prop_value.is_undefined()) { // i. Perform ! CreateDataPropertyOrThrow(merged, nextKey, propValue). - merged->create_data_property_or_throw(property_name, prop_value); + MUST(merged->create_data_property_or_throw(property_name, prop_value)); } // See comment above. @@ -995,7 +995,7 @@ ThrowCompletionOr default_merge_fields(GlobalObject& global_object, Obj // b. If month is not undefined, then if (!month.is_undefined()) { // i. Perform ! CreateDataPropertyOrThrow(merged, "month", month). - merged->create_data_property_or_throw(vm.names.month, month); + MUST(merged->create_data_property_or_throw(vm.names.month, month)); } // c. Let monthCode be ? Get(fields, "monthCode"). @@ -1004,7 +1004,7 @@ ThrowCompletionOr default_merge_fields(GlobalObject& global_object, Obj // d. If monthCode is not undefined, then if (!month_code.is_undefined()) { // i. Perform ! CreateDataPropertyOrThrow(merged, "monthCode", monthCode). - merged->create_data_property_or_throw(vm.names.monthCode, month_code); + MUST(merged->create_data_property_or_throw(vm.names.monthCode, month_code)); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp index d7014aa51b..c39b3abc09 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp @@ -356,16 +356,16 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::get_iso_fields) auto* fields = Object::create(global_object, global_object.object_prototype()); // 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", temporalDate.[[Calendar]]). - fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_date->calendar())); + MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_date->calendar()))); // 5. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", 𝔽(temporalDate.[[ISODay]])). - fields->create_data_property_or_throw(vm.names.isoDay, Value(temporal_date->iso_day())); + MUST(fields->create_data_property_or_throw(vm.names.isoDay, Value(temporal_date->iso_day()))); // 6. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", 𝔽(temporalDate.[[ISOMonth]])). - fields->create_data_property_or_throw(vm.names.isoMonth, Value(temporal_date->iso_month())); + MUST(fields->create_data_property_or_throw(vm.names.isoMonth, Value(temporal_date->iso_month()))); // 7. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", 𝔽(temporalDate.[[ISOYear]])). - fields->create_data_property_or_throw(vm.names.isoYear, Value(temporal_date->iso_year())); + MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(temporal_date->iso_year()))); // 8. Return fields. return fields; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp index ccdb183b1f..a005d7ab2d 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp @@ -553,34 +553,34 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::get_iso_fields) auto* fields = Object::create(global_object, global_object.object_prototype()); // 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", dateTime.[[Calendar]]). - fields->create_data_property_or_throw(vm.names.calendar, Value(&date_time->calendar())); + MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&date_time->calendar()))); // 5. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", 𝔽(dateTime.[[ISODay]])). - fields->create_data_property_or_throw(vm.names.isoDay, Value(date_time->iso_day())); + MUST(fields->create_data_property_or_throw(vm.names.isoDay, Value(date_time->iso_day()))); // 6. Perform ! CreateDataPropertyOrThrow(fields, "isoHour", 𝔽(dateTime.[[ISOHour]])). - fields->create_data_property_or_throw(vm.names.isoHour, Value(date_time->iso_hour())); + MUST(fields->create_data_property_or_throw(vm.names.isoHour, Value(date_time->iso_hour()))); // 7. Perform ! CreateDataPropertyOrThrow(fields, "isoMicrosecond", 𝔽(dateTime.[[ISOMicrosecond]])). - fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(date_time->iso_microsecond())); + MUST(fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(date_time->iso_microsecond()))); // 8. Perform ! CreateDataPropertyOrThrow(fields, "isoMillisecond", 𝔽(dateTime.[[ISOMillisecond]])). - fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(date_time->iso_millisecond())); + MUST(fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(date_time->iso_millisecond()))); // 9. Perform ! CreateDataPropertyOrThrow(fields, "isoMinute", 𝔽(dateTime.[[ISOMinute]])). - fields->create_data_property_or_throw(vm.names.isoMinute, Value(date_time->iso_minute())); + MUST(fields->create_data_property_or_throw(vm.names.isoMinute, Value(date_time->iso_minute()))); // 10. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", 𝔽(dateTime.[[ISOMonth]])). - fields->create_data_property_or_throw(vm.names.isoMonth, Value(date_time->iso_month())); + MUST(fields->create_data_property_or_throw(vm.names.isoMonth, Value(date_time->iso_month()))); // 11. Perform ! CreateDataPropertyOrThrow(fields, "isoNanosecond", 𝔽(dateTime.[[ISONanosecond]])). - fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(date_time->iso_nanosecond())); + MUST(fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(date_time->iso_nanosecond()))); // 12. Perform ! CreateDataPropertyOrThrow(fields, "isoSecond", 𝔽(dateTime.[[ISOSecond]])). - fields->create_data_property_or_throw(vm.names.isoSecond, Value(date_time->iso_second())); + MUST(fields->create_data_property_or_throw(vm.names.isoSecond, Value(date_time->iso_second()))); // 13. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", 𝔽(dateTime.[[ISOYear]])). - fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year())); + MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year()))); // 14. Return fields. return fields; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp index a70b448571..33c849763c 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp @@ -111,7 +111,7 @@ ThrowCompletionOr to_temporal_month_day(GlobalObject& global_obj // i. If calendarAbsent is true, and month is not undefined, and monthCode is undefined and year is undefined, then if (calendar_absent && !month.is_undefined() && month_code.is_undefined() && year.is_undefined()) { // i. Perform ! CreateDataPropertyOrThrow(fields, "year", 𝔽(referenceISOYear)). - fields->create_data_property_or_throw(vm.names.year, Value(reference_iso_year)); + MUST(fields->create_data_property_or_throw(vm.names.year, Value(reference_iso_year))); } // j. Return ? MonthDayFromFields(calendar, fields, options). diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp index ae30476e60..93ae24458e 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp @@ -181,16 +181,16 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::get_iso_fields) auto* fields = Object::create(global_object, global_object.object_prototype()); // 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", monthDay.[[Calendar]]). - fields->create_data_property_or_throw(vm.names.calendar, Value(&month_day->calendar())); + MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&month_day->calendar()))); // 5. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", 𝔽(monthDay.[[ISODay]])). - fields->create_data_property_or_throw(vm.names.isoDay, Value(month_day->iso_day())); + MUST(fields->create_data_property_or_throw(vm.names.isoDay, Value(month_day->iso_day()))); // 6. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", 𝔽(monthDay.[[ISOMonth]])). - fields->create_data_property_or_throw(vm.names.isoMonth, Value(month_day->iso_month())); + MUST(fields->create_data_property_or_throw(vm.names.isoMonth, Value(month_day->iso_month()))); // 7. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", 𝔽(monthDay.[[ISOYear]])). - fields->create_data_property_or_throw(vm.names.isoYear, Value(month_day->iso_year())); + MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(month_day->iso_year()))); // 8. Return fields. return fields; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp index 4f36f3c1f0..ec46c2d16b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp @@ -303,25 +303,25 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields) auto* fields = Object::create(global_object, global_object.object_prototype()); // 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", temporalTime.[[Calendar]]). - fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_time->calendar())); + MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&temporal_time->calendar()))); // 5. Perform ! CreateDataPropertyOrThrow(fields, "isoHour", 𝔽(temporalTime.[[ISOHour]])). - fields->create_data_property_or_throw(vm.names.isoHour, Value(temporal_time->iso_hour())); + MUST(fields->create_data_property_or_throw(vm.names.isoHour, Value(temporal_time->iso_hour()))); // 6. Perform ! CreateDataPropertyOrThrow(fields, "isoMicrosecond", 𝔽(temporalTime.[[ISOMicrosecond]])). - fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(temporal_time->iso_microsecond())); + MUST(fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(temporal_time->iso_microsecond()))); // 7. Perform ! CreateDataPropertyOrThrow(fields, "isoMillisecond", 𝔽(temporalTime.[[ISOMillisecond]])). - fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(temporal_time->iso_millisecond())); + MUST(fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(temporal_time->iso_millisecond()))); // 8. Perform ! CreateDataPropertyOrThrow(fields, "isoMinute", 𝔽(temporalTime.[[ISOMinute]])). - fields->create_data_property_or_throw(vm.names.isoMinute, Value(temporal_time->iso_minute())); + MUST(fields->create_data_property_or_throw(vm.names.isoMinute, Value(temporal_time->iso_minute()))); // 9. Perform ! CreateDataPropertyOrThrow(fields, "isoNanosecond", 𝔽(temporalTime.[[ISONanosecond]])). - fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(temporal_time->iso_nanosecond())); + MUST(fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(temporal_time->iso_nanosecond()))); // 10. Perform ! CreateDataPropertyOrThrow(fields, "isoSecond", 𝔽(temporalTime.[[ISOSecond]])). - fields->create_data_property_or_throw(vm.names.isoSecond, Value(temporal_time->iso_second())); + MUST(fields->create_data_property_or_throw(vm.names.isoSecond, Value(temporal_time->iso_second()))); // 11. Return fields. return fields; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp index 8040c06f8d..b1486a6121 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp @@ -302,16 +302,16 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::get_iso_fields) auto* fields = Object::create(global_object, global_object.object_prototype()); // 4. Perform ! CreateDataPropertyOrThrow(fields, "calendar", yearMonth.[[Calendar]]). - fields->create_data_property_or_throw(vm.names.calendar, Value(&year_month->calendar())); + MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&year_month->calendar()))); // 5. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", 𝔽(yearMonth.[[ISODay]])). - fields->create_data_property_or_throw(vm.names.isoDay, Value(year_month->iso_day())); + MUST(fields->create_data_property_or_throw(vm.names.isoDay, Value(year_month->iso_day()))); // 6. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", 𝔽(yearMonth.[[ISOMonth]])). - fields->create_data_property_or_throw(vm.names.isoMonth, Value(year_month->iso_month())); + MUST(fields->create_data_property_or_throw(vm.names.isoMonth, Value(year_month->iso_month()))); // 7. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", 𝔽(yearMonth.[[ISOYear]])). - fields->create_data_property_or_throw(vm.names.isoYear, Value(year_month->iso_year())); + MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(year_month->iso_year()))); // 8. Return fields. return fields; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index 45812eac3c..b6991fc55f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -887,40 +887,40 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields) auto offset = TRY_OR_DISCARD(builtin_time_zone_get_offset_string_for(global_object, &time_zone, *instant)); // 9. Perform ! CreateDataPropertyOrThrow(fields, "calendar", calendar). - fields->create_data_property_or_throw(vm.names.calendar, Value(&calendar)); + MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&calendar))); // 10. Perform ! CreateDataPropertyOrThrow(fields, "isoDay", dateTime.[[ISODay]]). - fields->create_data_property_or_throw(vm.names.isoDay, Value(date_time->iso_day())); + MUST(fields->create_data_property_or_throw(vm.names.isoDay, Value(date_time->iso_day()))); // 11. Perform ! CreateDataPropertyOrThrow(fields, "isoHour", dateTime.[[ISOHour]]). - fields->create_data_property_or_throw(vm.names.isoHour, Value(date_time->iso_hour())); + MUST(fields->create_data_property_or_throw(vm.names.isoHour, Value(date_time->iso_hour()))); // 12. Perform ! CreateDataPropertyOrThrow(fields, "isoMicrosecond", dateTime.[[ISOMicrosecond]]). - fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(date_time->iso_microsecond())); + MUST(fields->create_data_property_or_throw(vm.names.isoMicrosecond, Value(date_time->iso_microsecond()))); // 13. Perform ! CreateDataPropertyOrThrow(fields, "isoMillisecond", dateTime.[[ISOMillisecond]]). - fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(date_time->iso_millisecond())); + MUST(fields->create_data_property_or_throw(vm.names.isoMillisecond, Value(date_time->iso_millisecond()))); // 14. Perform ! CreateDataPropertyOrThrow(fields, "isoMinute", dateTime.[[ISOMinute]]). - fields->create_data_property_or_throw(vm.names.isoMinute, Value(date_time->iso_minute())); + MUST(fields->create_data_property_or_throw(vm.names.isoMinute, Value(date_time->iso_minute()))); // 15. Perform ! CreateDataPropertyOrThrow(fields, "isoMonth", dateTime.[[ISOMonth]]). - fields->create_data_property_or_throw(vm.names.isoMonth, Value(date_time->iso_month())); + MUST(fields->create_data_property_or_throw(vm.names.isoMonth, Value(date_time->iso_month()))); // 16. Perform ! CreateDataPropertyOrThrow(fields, "isoNanosecond", dateTime.[[ISONanosecond]]). - fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(date_time->iso_nanosecond())); + MUST(fields->create_data_property_or_throw(vm.names.isoNanosecond, Value(date_time->iso_nanosecond()))); // 17. Perform ! CreateDataPropertyOrThrow(fields, "isoSecond", dateTime.[[ISOSecond]]). - fields->create_data_property_or_throw(vm.names.isoSecond, Value(date_time->iso_second())); + MUST(fields->create_data_property_or_throw(vm.names.isoSecond, Value(date_time->iso_second()))); // 18. Perform ! CreateDataPropertyOrThrow(fields, "isoYear", dateTime.[[ISOYear]]). - fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year())); + MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year()))); // 19. Perform ! CreateDataPropertyOrThrow(fields, "offset", offset). - fields->create_data_property_or_throw(vm.names.offset, js_string(vm, offset)); + MUST(fields->create_data_property_or_throw(vm.names.offset, js_string(vm, offset))); // 20. Perform ! CreateDataPropertyOrThrow(fields, "timeZone", timeZone). - fields->create_data_property_or_throw(vm.names.timeZone, Value(&time_zone)); + MUST(fields->create_data_property_or_throw(vm.names.timeZone, Value(&time_zone))); // 21. Return fields. return fields;