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

LibJS: Convert initialize_binding() to ThrowCompletionOr

Also add spec step comments to it while we're here.
This commit is contained in:
Linus Groh 2021-10-09 19:16:24 +01:00
parent 2691c65639
commit ae397541fb
12 changed files with 50 additions and 36 deletions

View file

@ -76,9 +76,13 @@ ThrowCompletionOr<void> ObjectEnvironment::create_immutable_binding(GlobalObject
}
// 9.1.1.2.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-object-environment-records-initializebinding-n-v
void ObjectEnvironment::initialize_binding(GlobalObject& global_object, FlyString const& name, Value value)
ThrowCompletionOr<void> ObjectEnvironment::initialize_binding(GlobalObject& global_object, FlyString const& name, Value value)
{
// 1. Return ? envRec.SetMutableBinding(N, V, false).
set_mutable_binding(global_object, name, value, false);
if (auto* exception = vm().exception())
return throw_completion(exception->value());
return {};
}
// 9.1.1.2.5 SetMutableBinding ( N, V, S ), https://tc39.es/ecma262/#sec-object-environment-records-setmutablebinding-n-v-s