diff options
author | davidot <davidot@serenityos.org> | 2021-10-22 00:23:32 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-24 08:38:02 +0100 |
commit | 9c9aaf4d4f834dccf21ddc543fc05898708e0f2f (patch) | |
tree | 98714c47c4af2a18d1ce42708116dc734a8e25d9 | |
parent | ff1b72c95c1c58f1051269e7e66e36c06bdea481 (diff) | |
download | serenity-9c9aaf4d4f834dccf21ddc543fc05898708e0f2f.zip |
LibJS: Don't VERIFY that a function is Regular when executing in AST
By replacing this VERIFY with a thrown Error we no longer crash when
calling a generator function in the AST interpreter. This allows us to
more gracefully handle situation which have not been implemented yet.
In particular this helps the libjs-test262-runner since it can now
continue on to the next tests instead of having the entire process end.
-rw-r--r-- | Userland/Libraries/LibJS/AST.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ErrorTypes.h | 1 |
3 files changed, 5 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 411a578361..913a3c1516 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -3371,11 +3371,11 @@ void ScopeNode::add_hoisted_function(NonnullRefPtr<FunctionDeclaration> declarat m_functions_hoistable_with_annexB_extension.append(move(declaration)); } -Value ImportStatement::execute(Interpreter& interpreter, GlobalObject&) const +Value ImportStatement::execute(Interpreter& interpreter, GlobalObject& global_object) const { InterpreterNodeScope node_scope { interpreter, *this }; dbgln("Modules are not fully supported yet!"); - TODO(); + interpreter.vm().throw_exception<InternalError>(global_object, ErrorType::NotImplemented, "'import' in modules"); return {}; } diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 8a56158e6c..b06b2235bc 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -697,7 +697,8 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body() return normal_completion(GeneratorObject::create(global_object(), result, this, vm.running_execution_context().lexical_environment, bytecode_interpreter->snapshot_frame())); } else { - VERIFY(m_kind != FunctionKind::Generator); + if (m_kind != FunctionKind::Regular) + return vm.throw_completion<InternalError>(global_object(), ErrorType::NotImplemented, "Non regular function execution in AST interpreter"); OwnPtr<Interpreter> local_interpreter; Interpreter* ast_interpreter = vm.interpreter_if_exists(); diff --git a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h index 4bb5ff35bd..db091065f8 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h @@ -72,6 +72,7 @@ M(NotAnObjectOrString, "{} is neither an object nor a string") \ M(NotAString, "{} is not a string") \ M(NotASymbol, "{} is not a symbol") \ + M(NotImplemented, "TODO({} is not implemented in LibJS)") \ M(NotIterable, "{} is not iterable") \ M(NotObjectCoercible, "{} cannot be converted to an object") \ M(NotUndefined, "{} is not undefined") \ |