From 5407fe8fcf211e2bda737c141b12bd8cafe78835 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sat, 2 Apr 2022 12:00:43 +0430 Subject: [PATCH] LibJS: Make Handle::is_null() also consider the contained value Previously this would've said `make_handle(Value(1234))` is null, as it did not contain a cell (but rather a plain Value), which made throwing primitives spin forever in BC mode. --- Userland/Libraries/LibJS/Heap/Handle.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibJS/Heap/Handle.h b/Userland/Libraries/LibJS/Heap/Handle.h index 3fa2a01c29..bdb97c022d 100644 --- a/Userland/Libraries/LibJS/Heap/Handle.h +++ b/Userland/Libraries/LibJS/Heap/Handle.h @@ -95,8 +95,8 @@ public: auto cell() { return m_handle.cell(); } auto cell() const { return m_handle.cell(); } - auto value() const { return m_value; } - bool is_null() const { return m_handle.is_null(); } + auto value() const { return *m_value; } + bool is_null() const { return m_handle.is_null() && !m_value.has_value(); } private: explicit Handle(Value value) @@ -110,7 +110,7 @@ private: { } - Value m_value; + Optional m_value; Handle m_handle; };