1
Fork 0
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:
Linus Groh 2021-10-20 17:55:39 +01:00
parent 1d4919bb81
commit 8feae81025
2 changed files with 3 additions and 2 deletions

View file

@ -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);