From 3fb678b3766d9595bf885002d9f7134000653f80 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 28 Oct 2025 18:48:41 +0100 Subject: [PATCH] LibGC: Delete operators ! and bool from GC::Ref The GC::Ref smart pointer is always non-null, so there's no need for it to be convertible to bool. This exposed a small number of unnecessary null checks which we remove. --- Libraries/LibGC/Ptr.h | 3 +++ Libraries/LibJS/AST.cpp | 1 - Libraries/LibJS/Bytecode/Interpreter.cpp | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Libraries/LibGC/Ptr.h b/Libraries/LibGC/Ptr.h index 8376698312..5784101c42 100644 --- a/Libraries/LibGC/Ptr.h +++ b/Libraries/LibGC/Ptr.h @@ -71,6 +71,9 @@ public: operator T&() const { return *m_ptr; } + operator bool() const = delete; + bool operator!() const = delete; + private: T* m_ptr { nullptr }; }; diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index 75bb934d0c..e8e5bb7f90 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -322,7 +322,6 @@ ThrowCompletionOr ClassExpression::create_class_const } auto prototype = Object::create_prototype(realm, proto_parent); - VERIFY(prototype); // FIXME: Step 14.a is done in the parser. By using a synthetic super(...args) which does not call @@iterator of %Array.prototype% auto const& constructor = *m_constructor; diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index b08914aaa2..6fa3ebe5cc 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -1344,7 +1344,6 @@ static Value instantiate_ordinary_function_expression(Interpreter& interpreter, auto environment = GC::Ref { *interpreter.running_execution_context().lexical_environment }; if (has_own_name) { - VERIFY(environment); environment = new_declarative_environment(*environment); MUST(environment->create_immutable_binding(interpreter.vm(), own_name, false)); }