1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

LibJS: Convert can_declare_global_function() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-12-29 15:56:53 +01:00
parent 215a56b0e4
commit 8296d3fbd2
4 changed files with 14 additions and 12 deletions

View file

@ -215,18 +215,18 @@ ThrowCompletionOr<bool> GlobalEnvironment::can_declare_global_var(FlyString cons
}
// 9.1.1.4.16 CanDeclareGlobalFunction ( N ), https://tc39.es/ecma262/#sec-candeclareglobalfunction
bool GlobalEnvironment::can_declare_global_function(FlyString const& name) const
ThrowCompletionOr<bool> GlobalEnvironment::can_declare_global_function(FlyString const& name) const
{
// 1. Let ObjRec be envRec.[[ObjectRecord]].
// 2. Let globalObject be ObjRec.[[BindingObject]].
auto& global_object = m_object_record->binding_object();
// 3. Let existingProp be ? globalObject.[[GetOwnProperty]](N).
auto existing_prop = TRY_OR_DISCARD(global_object.internal_get_own_property(name));
auto existing_prop = TRY(global_object.internal_get_own_property(name));
// 4. If existingProp is undefined, return ? IsExtensible(globalObject).
if (!existing_prop.has_value())
return TRY_OR_DISCARD(global_object.is_extensible());
return TRY(global_object.is_extensible());
// 5. If existingProp.[[Configurable]] is true, return true.
if (*existing_prop->configurable)