1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:57:35 +00:00

LibJS: Make Handle<Value>::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.
This commit is contained in:
Ali Mohammad Pur 2022-04-02 12:00:43 +04:30 committed by Andreas Kling
parent 431776ebb7
commit 5407fe8fcf

View file

@ -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<Value> m_value;
Handle<Cell> m_handle;
};