diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 46ec07153db..3a8ddd7dbb7 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -293,7 +293,7 @@ ThrowCompletionOr StaticInitializer::class_element_eva return ClassValue { normal_completion(body_function) }; } -ThrowCompletionOr ClassExpression::create_class_constructor(VM& vm, Environment* class_environment, Environment* environment, Value super_class, DeprecatedFlyString const& binding_name, DeprecatedFlyString const& class_name) const +ThrowCompletionOr ClassExpression::create_class_constructor(VM& vm, Environment* class_environment, Environment* environment, Value super_class, Optional const& binding_name, DeprecatedFlyString const& class_name) const { auto& realm = *vm.current_realm(); @@ -421,8 +421,8 @@ ThrowCompletionOr ClassExpression::create_class_const vm.running_execution_context().lexical_environment = environment; restore_environment.disarm(); - if (!binding_name.is_null()) - MUST(class_environment->initialize_binding(vm, binding_name, class_constructor, Environment::InitializeBindingHint::Normal)); + if (binding_name.has_value()) + MUST(class_environment->initialize_binding(vm, binding_name.value(), class_constructor, Environment::InitializeBindingHint::Normal)); for (auto& field : instance_fields) class_constructor->add_field(field); @@ -451,7 +451,7 @@ ThrowCompletionOr ClassExpression::create_class_const return { class_constructor }; } -ThrowCompletionOr ClassExpression::class_definition_evaluation(VM& vm, DeprecatedFlyString const& binding_name, DeprecatedFlyString const& class_name) const +ThrowCompletionOr ClassExpression::class_definition_evaluation(VM& vm, Optional const& binding_name, DeprecatedFlyString const& class_name) const { auto* environment = vm.lexical_environment(); VERIFY(environment); @@ -459,8 +459,8 @@ ThrowCompletionOr ClassExpression::class_definition_e Value super_class; - if (!binding_name.is_null()) - MUST(class_environment->create_immutable_binding(vm, binding_name, true)); + if (binding_name.has_value()) + MUST(class_environment->create_immutable_binding(vm, binding_name.value(), true)); if (!m_super_class.is_null()) { vm.running_execution_context().lexical_environment = class_environment; diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h index 2a948413df3..bfc599aab3f 100644 --- a/Userland/Libraries/LibJS/AST.h +++ b/Userland/Libraries/LibJS/AST.h @@ -1418,8 +1418,8 @@ public: bool has_name() const { return m_name; } - ThrowCompletionOr class_definition_evaluation(VM&, DeprecatedFlyString const& binding_name = {}, DeprecatedFlyString const& class_name = {}) const; - ThrowCompletionOr create_class_constructor(VM&, Environment* class_environment, Environment* environment, Value super_class, DeprecatedFlyString const& binding_name = {}, DeprecatedFlyString const& class_name = {}) const; + ThrowCompletionOr class_definition_evaluation(VM&, Optional const& binding_name = {}, DeprecatedFlyString const& class_name = {}) const; + ThrowCompletionOr create_class_constructor(VM&, Environment* class_environment, Environment* environment, Value super_class, Optional const& binding_name = {}, DeprecatedFlyString const& class_name = {}) const; private: virtual bool is_class_expression() const override { return true; } diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h index af5210b4a79..0f5831f5788 100644 --- a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h +++ b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h @@ -611,7 +611,7 @@ inline ThrowCompletionOr new_class(VM& vm, Value supe auto* class_environment = vm.lexical_environment(); vm.running_execution_context().lexical_environment = interpreter.saved_lexical_environment_stack().take_last(); - DeprecatedFlyString binding_name; + Optional binding_name; DeprecatedFlyString class_name; if (!class_expression.has_name() && lhs_name.has_value()) { class_name = interpreter.current_executable().get_identifier(lhs_name.value());