summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2021-10-14 00:25:40 +0200
committerLinus Groh <mail@linusgroh.de>2021-10-15 10:27:16 +0100
commitc3cb44ca8a5a25fa6362e4a73e138acac7ee2acd (patch)
treefc2516784e6462d772d04218b3576b650c4c8bb9 /Userland
parent1fe6a422f13200fe885ab9ccdc1626f18e6c12b9 (diff)
downloadserenity-c3cb44ca8a5a25fa6362e4a73e138acac7ee2acd.zip
LibJS: Remove ErrorType::FixmeAddAnErrorStringWithMessage
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/AST.cpp12
-rw-r--r--Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp8
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorTypes.h5
3 files changed, 14 insertions, 11 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp
index 5339e5e2d3..3d175393c1 100644
--- a/Userland/Libraries/LibJS/AST.cpp
+++ b/Userland/Libraries/LibJS/AST.cpp
@@ -3213,7 +3213,7 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i
{
for_each_lexically_declared_name([&](FlyString const& name) {
if (global_environment.has_var_declaration(name) || global_environment.has_lexical_declaration(name)) {
- interpreter.vm().throw_exception<SyntaxError>(global_object, ErrorType::FixmeAddAnErrorStringWithMessage, "Lexical variable top level already declared");
+ interpreter.vm().throw_exception<SyntaxError>(global_object, ErrorType::TopLevelVariableAlreadyDeclared, name);
return IterationDecision::Break;
}
@@ -3222,7 +3222,7 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i
return IterationDecision::Break;
if (restricted_global)
- interpreter.vm().throw_exception<SyntaxError>(global_object, ErrorType::FixmeAddAnErrorStringWithMessage, "Restricted global property");
+ interpreter.vm().throw_exception<SyntaxError>(global_object, ErrorType::RestrictedGlobalProperty, name);
return IterationDecision::Continue;
});
@@ -3232,7 +3232,7 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i
for_each_var_declared_name([&](auto const& name) {
if (global_environment.has_lexical_declaration(name)) {
- interpreter.vm().throw_exception<SyntaxError>(global_object, ErrorType::FixmeAddAnErrorStringWithMessage, "Var declared variable top level also lexically declared");
+ interpreter.vm().throw_exception<SyntaxError>(global_object, ErrorType::TopLevelVariableAlreadyDeclared, name);
return IterationDecision::Break;
}
@@ -3255,7 +3255,7 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i
return IterationDecision::Break;
if (!function_definable) {
- interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::FixmeAddAnErrorStringWithMessage, "Global function not definable");
+ interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::CannotDeclareGlobalFunction, function.name());
return IterationDecision::Break;
}
@@ -3278,7 +3278,7 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i
return IterationDecision::Break;
if (!var_definable) {
- interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::FixmeAddAnErrorStringWithMessage, "Global variable not definable");
+ interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::CannotDeclareGlobalVariable, name);
return IterationDecision::Break;
}
@@ -3305,7 +3305,7 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i
return IterationDecision::Break;
if (!function_definable) {
- interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::FixmeAddAnErrorStringWithMessage, "Global function not definable");
+ interpreter.vm().throw_exception<TypeError>(global_object, ErrorType::CannotDeclareGlobalFunction, function_name);
return IterationDecision::Break;
}
diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
index 3a7ff1ca66..9b135b425a 100644
--- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
@@ -547,7 +547,7 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo
if (global_var_environment) {
program.for_each_var_declared_name([&](auto const& name) {
if (global_var_environment->has_lexical_declaration(name)) {
- vm.throw_exception<SyntaxError>(global_object, ErrorType::FixmeAddAnErrorStringWithMessage, "Var already declared lexically");
+ vm.throw_exception<SyntaxError>(global_object, ErrorType::TopLevelVariableAlreadyDeclared, name);
return IterationDecision::Break;
}
return IterationDecision::Continue;
@@ -559,7 +559,7 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo
if (!is<ObjectEnvironment>(*this_environment)) {
program.for_each_var_declared_name([&](auto const& name) {
if (MUST(this_environment->has_binding(name))) {
- vm.throw_exception<SyntaxError>(global_object, ErrorType::FixmeAddAnErrorStringWithMessage, "Var already declared lexically");
+ vm.throw_exception<SyntaxError>(global_object, ErrorType::TopLevelVariableAlreadyDeclared, name);
return IterationDecision::Break;
}
// FIXME: NOTE: Annex B.3.4 defines alternate semantics for the above step.
@@ -586,7 +586,7 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo
if (vm.exception())
return IterationDecision::Break;
if (!function_definable) {
- vm.throw_exception<TypeError>(global_object, ErrorType::FixmeAddAnErrorStringWithMessage, "Cannot define global function");
+ vm.throw_exception<TypeError>(global_object, ErrorType::CannotDeclareGlobalFunction, function.name());
return IterationDecision::Break;
}
}
@@ -656,7 +656,7 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo
if (vm.exception())
return IterationDecision::Break;
if (!variable_definable) {
- vm.throw_exception<TypeError>(global_object, ErrorType::FixmeAddAnErrorStringWithMessage, "Cannot define global var");
+ vm.throw_exception<TypeError>(global_object, ErrorType::CannotDeclareGlobalVariable, name);
return IterationDecision::Break;
}
}
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
index 849f49b893..9a203b365b 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
+++ b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
@@ -16,6 +16,8 @@
M(BigIntInvalidValue, "Invalid value for BigInt: {}") \
M(BindingNotInitialized, "Binding {} is not initialized") \
M(CallStackSizeExceeded, "Call stack size limit exceeded") \
+ M(CannotDeclareGlobalFunction, "Cannot declare global function of name '{}'") \
+ M(CannotDeclareGlobalVariable, "Cannot declare global variable of name '{}'") \
M(ClassConstructorWithoutNew, "Class constructor {} must be called with 'new'") \
M(ClassExtendsValueNotAConstructorOrNull, "Class extends value {} is not a constructor or null") \
M(ClassExtendsValueInvalidPrototype, "Class extends value has an invalid prototype {}") \
@@ -171,6 +173,7 @@
M(RegExpObjectRepeatedFlag, "Repeated RegExp flag '{}'") \
M(RestrictedFunctionPropertiesAccess, "Restricted function properties like 'callee', 'caller' and 'arguments' may " \
"not be accessed in strict mode") \
+ M(RestrictedGlobalProperty, "Cannot declare global property '{}'") \
M(ShadowRealmEvaluateAbruptCompletion, "The evaluated script did not complete normally") \
M(ShadowRealmWrappedValueNonFunctionObject, "Wrapped value must be primitive or a function object, got {}") \
M(SpeciesConstructorDidNotCreate, "Species constructor did not create {}") \
@@ -209,6 +212,7 @@
M(ThisHasNotBeenInitialized, "|this| has not been initialized") \
M(ThisIsAlreadyInitialized, "|this| is already initialized") \
M(ToObjectNullOrUndefined, "ToObject on null or undefined") \
+ M(TopLevelVariableAlreadyDeclared, "Redeclaration of top level variable '{}'") \
M(ToPrimitiveReturnedObject, "Can't convert {} to primitive with hint \"{}\", its @@toPrimitive method returned an object") \
M(TypedArrayContentTypeMismatch, "Can't create {} from {}") \
M(TypedArrayInvalidBufferLength, "Invalid buffer length for {}: must be a multiple of {}, got {}") \
@@ -227,7 +231,6 @@
M(BadArgCountAtLeastOne, "{}() needs at least one argument") \
M(BadArgCountMany, "{}() needs {} arguments") \
M(FixmeAddAnErrorString, "FIXME: Add a string for this error.") \
- M(FixmeAddAnErrorStringWithMessage, "FIXME: Add a real string for this error '{}'") \
M(NotEnoughMemoryToAllocate, "Not enough memory to allocate {} bytes")
namespace JS {