diff options
author | Linus Groh <mail@linusgroh.de> | 2021-10-20 17:55:39 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-20 18:46:24 +0100 |
commit | 8feae8102594a68a5ec23c6f1b24630255cc88fd (patch) | |
tree | fdd85fd64a01c61327c8601a67cbdf3c7ff51d1e /Userland | |
parent | 1d4919bb81418d2726486a9711e7b4fdb0b846f1 (diff) | |
download | serenity-8feae8102594a68a5ec23c6f1b24630255cc88fd.zip |
LibJS: Add ErrorType for duplicate global environment binding
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ErrorTypes.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h index 9a203b365b..b1da75690d 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h @@ -31,6 +31,7 @@ M(DivisionByZero, "Division by zero") \ M(FinalizationRegistrySameTargetAndValue, "Target and held value must not be the same") \ 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(InOperatorWithObject, "'in' operator must be used on an object") \ M(InstanceOfOperatorBadPrototype, "'prototype' property of {} is not an object") \ diff --git a/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp index d2dbf2bb25..94d2133f57 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp @@ -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); |