mirror of
https://github.com/RGBCube/serenity
synced 2025-06-28 21:22:08 +00:00
LibJS: Make Value::to_string_without_side_effects() infallible
Work towards #20449.
This commit is contained in:
parent
b8f78c0adc
commit
97ebfd9f0f
69 changed files with 182 additions and 182 deletions
|
@ -41,7 +41,7 @@ namespace JS {
|
|||
ThrowCompletionOr<Value> require_object_coercible(VM& vm, Value value)
|
||||
{
|
||||
if (value.is_nullish())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotObjectCoercible, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotObjectCoercible, value.to_string_without_side_effects());
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ ThrowCompletionOr<Value> call_impl(VM& vm, Value function, Value this_value, Opt
|
|||
|
||||
// 2. If IsCallable(F) is false, throw a TypeError exception.
|
||||
if (!function.is_function())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, function.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, function.to_string_without_side_effects());
|
||||
|
||||
// 3. Return ? F.[[Call]](V, argumentsList).
|
||||
return function.as_function().internal_call(this_value, move(*arguments_list));
|
||||
|
@ -102,7 +102,7 @@ ThrowCompletionOr<MarkedVector<Value>> create_list_from_array_like(VM& vm, Value
|
|||
|
||||
// 2. If Type(obj) is not Object, throw a TypeError exception.
|
||||
if (!value.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, value.to_string_without_side_effects());
|
||||
|
||||
auto& array_like = value.as_object();
|
||||
|
||||
|
@ -146,7 +146,7 @@ ThrowCompletionOr<FunctionObject*> species_constructor(VM& vm, Object const& obj
|
|||
|
||||
// 3. If Type(C) is not Object, throw a TypeError exception.
|
||||
if (!constructor.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, constructor.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_string_without_side_effects());
|
||||
|
||||
// 4. Let S be ? Get(C, @@species).
|
||||
auto species = TRY(constructor.as_object().get(vm.well_known_symbol_species()));
|
||||
|
@ -160,7 +160,7 @@ ThrowCompletionOr<FunctionObject*> species_constructor(VM& vm, Object const& obj
|
|||
return &species.as_function();
|
||||
|
||||
// 7. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, TRY_OR_THROW_OOM(vm, species.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, species.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
// 7.3.25 GetFunctionRealm ( obj ), https://tc39.es/ecma262/#sec-getfunctionrealm
|
||||
|
@ -1331,7 +1331,7 @@ ThrowCompletionOr<void> add_disposable_resource(VM& vm, Vector<DisposableResourc
|
|||
|
||||
// b. If Type(V) is not Object, throw a TypeError exception.
|
||||
if (!value.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, value.to_string_without_side_effects());
|
||||
|
||||
// c. Let resource be ? CreateDisposableResource(V, hint).
|
||||
resource = TRY(create_disposable_resource(vm, value, hint));
|
||||
|
@ -1347,7 +1347,7 @@ ThrowCompletionOr<void> add_disposable_resource(VM& vm, Vector<DisposableResourc
|
|||
else {
|
||||
// i. If Type(V) is not Object, throw a TypeError exception.
|
||||
if (!value.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, value.to_string_without_side_effects());
|
||||
|
||||
// ii. Let resource be ? CreateDisposableResource(V, hint, method).
|
||||
resource = TRY(create_disposable_resource(vm, value, hint, method));
|
||||
|
@ -1376,7 +1376,7 @@ ThrowCompletionOr<DisposableResource> create_disposable_resource(VM& vm, Value v
|
|||
|
||||
// c. If method is undefined, throw a TypeError exception.
|
||||
if (!method)
|
||||
return vm.throw_completion<TypeError>(ErrorType::NoDisposeMethod, TRY_OR_THROW_OOM(vm, value.to_string_without_side_effects()));
|
||||
return vm.throw_completion<TypeError>(ErrorType::NoDisposeMethod, value.to_string_without_side_effects());
|
||||
}
|
||||
// 2. Else,
|
||||
// a. If IsCallable(method) is false, throw a TypeError exception.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue