mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 02:38:13 +00:00
LibJS: Add ErrorType for duplicate global environment binding
This commit is contained in:
parent
1d4919bb81
commit
8feae81025
2 changed files with 3 additions and 2 deletions
|
@ -57,7 +57,7 @@ ThrowCompletionOr<void> GlobalEnvironment::create_mutable_binding(GlobalObject&
|
|||
// 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);
|
||||
return vm().throw_completion<TypeError>(global_object, ErrorType::GlobalEnvironmentAlreadyHasBinding, name);
|
||||
|
||||
// 3. Return DclRec.CreateMutableBinding(N, D).
|
||||
return m_declarative_record->create_mutable_binding(global_object, name, can_be_deleted);
|
||||
|
@ -69,7 +69,7 @@ ThrowCompletionOr<void> GlobalEnvironment::create_immutable_binding(GlobalObject
|
|||
// 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);
|
||||
return vm().throw_completion<TypeError>(global_object, ErrorType::GlobalEnvironmentAlreadyHasBinding, name);
|
||||
|
||||
// 3. Return DclRec.CreateImmutableBinding(N, S).
|
||||
return m_declarative_record->create_immutable_binding(global_object, name, strict);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue