1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

LibJS: Set class' source text in NewClass instruction

This fixes the classes toString method.
This commit is contained in:
Hendiadyoin1 2022-10-02 11:50:13 +02:00 committed by Linus Groh
parent 7618f2290f
commit baa4d69668

View file

@ -944,7 +944,10 @@ ThrowCompletionOr<void> 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 {};
}