mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07: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
|
@ -64,13 +64,15 @@ ThrowCompletionOr<void> GlobalEnvironment::create_mutable_binding(GlobalObject&
|
|||
}
|
||||
|
||||
// 9.1.1.4.3 CreateImmutableBinding ( N, S ), https://tc39.es/ecma262/#sec-global-environment-records-createimmutablebinding-n-s
|
||||
void GlobalEnvironment::create_immutable_binding(GlobalObject& global_object, FlyString const& name, bool strict)
|
||||
ThrowCompletionOr<void> GlobalEnvironment::create_immutable_binding(GlobalObject& global_object, FlyString const& name, bool strict)
|
||||
{
|
||||
if (MUST(m_declarative_record->has_binding(name))) {
|
||||
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::FixmeAddAnErrorString);
|
||||
return;
|
||||
}
|
||||
m_declarative_record->create_immutable_binding(global_object, name, strict);
|
||||
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
||||
// 2. If DclRec.HasBinding(N) is true, throw a TypeError exception.
|
||||
if (MUST(m_declarative_record->has_binding(name)))
|
||||
return vm().throw_completion<TypeError>(global_object, ErrorType::FixmeAddAnErrorString);
|
||||
|
||||
// 3. Return DclRec.CreateImmutableBinding(N, S).
|
||||
return m_declarative_record->create_immutable_binding(global_object, name, strict);
|
||||
}
|
||||
|
||||
// 9.1.1.4.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-global-environment-records-initializebinding-n-v
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue