From baa4d6966814f336f534db8485c1e9acd84e0447 Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Sun, 2 Oct 2022 11:50:13 +0200 Subject: LibJS: Set class' source text in NewClass instruction This fixes the classes toString method. --- Userland/Libraries/LibJS/Bytecode/Op.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries/LibJS') diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 07a029ba8a..58be7e29d6 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -944,7 +944,10 @@ ThrowCompletionOr NewClass::execute_impl(Bytecode::Interpreter& interprete auto name = m_class_expression.name(); auto scope = interpreter.ast_interpreter_scope(); auto& ast_interpreter = scope.interpreter(); - auto class_object = TRY(m_class_expression.class_definition_evaluation(ast_interpreter, name, name.is_null() ? ""sv : name)); + + auto* class_object = TRY(m_class_expression.class_definition_evaluation(ast_interpreter, name, name.is_null() ? ""sv : name)); + class_object->set_source_text(m_class_expression.source_text()); + interpreter.accumulator() = class_object; return {}; } -- cgit v1.2.3