mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
LibJS: Convert create_immutable_binding() to ThrowCompletionOr
Also add spec step comments to it while we're here.
This commit is contained in:
parent
4baf3a91e8
commit
2691c65639
10 changed files with 29 additions and 22 deletions
|
@ -66,8 +66,9 @@ ThrowCompletionOr<void> DeclarativeEnvironment::create_mutable_binding(GlobalObj
|
|||
}
|
||||
|
||||
// 9.1.1.1.3 CreateImmutableBinding ( N, S ), https://tc39.es/ecma262/#sec-declarative-environment-records-createimmutablebinding-n-s
|
||||
void DeclarativeEnvironment::create_immutable_binding(GlobalObject&, FlyString const& name, bool strict)
|
||||
ThrowCompletionOr<void> DeclarativeEnvironment::create_immutable_binding(GlobalObject&, FlyString const& name, bool strict)
|
||||
{
|
||||
// 2. Create an immutable binding in envRec for N and record that it is uninitialized. If S is true, record that the newly created binding is a strict binding.
|
||||
m_bindings.append(Binding {
|
||||
.value = {},
|
||||
.strict = strict,
|
||||
|
@ -76,7 +77,12 @@ void DeclarativeEnvironment::create_immutable_binding(GlobalObject&, FlyString c
|
|||
.initialized = false,
|
||||
});
|
||||
auto result = m_names.set(name, m_bindings.size() - 1);
|
||||
|
||||
// 1. Assert: envRec does not already have a binding for N.
|
||||
VERIFY(result == AK::HashSetResult::InsertedNewEntry);
|
||||
|
||||
// 3. Return NormalCompletion(empty).
|
||||
return {};
|
||||
}
|
||||
|
||||
// 9.1.1.1.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-declarative-environment-records-initializebinding-n-v
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue