mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +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
|
@ -31,6 +31,7 @@
|
||||||
M(DivisionByZero, "Division by zero") \
|
M(DivisionByZero, "Division by zero") \
|
||||||
M(FinalizationRegistrySameTargetAndValue, "Target and held value must not be the same") \
|
M(FinalizationRegistrySameTargetAndValue, "Target and held value must not be the same") \
|
||||||
M(GetCapabilitiesExecutorCalledMultipleTimes, "GetCapabilitiesExecutor was called multiple times") \
|
M(GetCapabilitiesExecutorCalledMultipleTimes, "GetCapabilitiesExecutor was called multiple times") \
|
||||||
|
M(GlobalEnvironmentAlreadyHasBinding, "Global environment already has binding '{}'") \
|
||||||
M(IndexOutOfRange, "Index {} is out of range of array length {}") \
|
M(IndexOutOfRange, "Index {} is out of range of array length {}") \
|
||||||
M(InOperatorWithObject, "'in' operator must be used on an object") \
|
M(InOperatorWithObject, "'in' operator must be used on an object") \
|
||||||
M(InstanceOfOperatorBadPrototype, "'prototype' property of {} is not an object") \
|
M(InstanceOfOperatorBadPrototype, "'prototype' property of {} is not an object") \
|
||||||
|
|
|
@ -57,7 +57,7 @@ ThrowCompletionOr<void> GlobalEnvironment::create_mutable_binding(GlobalObject&
|
||||||
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
||||||
// 2. If DclRec.HasBinding(N) is true, throw a TypeError exception.
|
// 2. If DclRec.HasBinding(N) is true, throw a TypeError exception.
|
||||||
if (MUST(m_declarative_record->has_binding(name)))
|
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).
|
// 3. Return DclRec.CreateMutableBinding(N, D).
|
||||||
return m_declarative_record->create_mutable_binding(global_object, name, can_be_deleted);
|
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]].
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
||||||
// 2. If DclRec.HasBinding(N) is true, throw a TypeError exception.
|
// 2. If DclRec.HasBinding(N) is true, throw a TypeError exception.
|
||||||
if (MUST(m_declarative_record->has_binding(name)))
|
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).
|
// 3. Return DclRec.CreateImmutableBinding(N, S).
|
||||||
return m_declarative_record->create_immutable_binding(global_object, name, strict);
|
return m_declarative_record->create_immutable_binding(global_object, name, strict);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue