summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-07-05 12:57:17 +0100
committerLinus Groh <mail@linusgroh.de>2021-07-05 13:53:30 +0100
commitfe9dc473204d79e868dbc28c70976be3a9d3a64b (patch)
tree491914df08c4712b652c2ef02a0f094c048d9fdd /Userland/Libraries
parent83f3f396add7f17b606cb156b4afe653c4dc8bda (diff)
downloadserenity-fe9dc473204d79e868dbc28c70976be3a9d3a64b.zip
LibJS: Make FunctionObject's m_home_object an Object*, not Value
As the name implies (and the spec confirms), this is only ever going to be an object or "nothing", or "undefined" in the spec. By taking this literally and updating a check to check for `is_undefined()`, we introduced a bug - the value was still initialized as an empty value. Instead, use a pointer to an Object - either we have one, or we don't. Fixes #8448.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/FunctionObject.h6
2 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp
index 62ebfb403c..d130d8a8e7 100644
--- a/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp
@@ -33,9 +33,9 @@ Value FunctionEnvironment::get_super_base() const
{
VERIFY(m_function_object);
auto home_object = m_function_object->home_object();
- if (home_object.is_undefined())
+ if (!home_object)
return js_undefined();
- return home_object.as_object().internal_get_prototype_of();
+ return home_object->internal_get_prototype_of();
}
// 9.1.1.3.2 HasThisBinding ( ), https://tc39.es/ecma262/#sec-function-environment-records-hasthisbinding
@@ -51,7 +51,7 @@ bool FunctionEnvironment::has_super_binding() const
{
if (this_binding_status() == ThisBindingStatus::Lexical)
return false;
- if (function_object().home_object().is_undefined())
+ if (!function_object().home_object())
return false;
return true;
}
diff --git a/Userland/Libraries/LibJS/Runtime/FunctionObject.h b/Userland/Libraries/LibJS/Runtime/FunctionObject.h
index c98d4fc141..5b089877b1 100644
--- a/Userland/Libraries/LibJS/Runtime/FunctionObject.h
+++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.h
@@ -34,8 +34,8 @@ public:
const Vector<Value>& bound_arguments() const { return m_bound_arguments; }
- Value home_object() const { return m_home_object; }
- void set_home_object(Value home_object) { m_home_object = home_object; }
+ Object* home_object() const { return m_home_object; }
+ void set_home_object(Object* home_object) { m_home_object = home_object; }
ConstructorKind constructor_kind() const { return m_constructor_kind; };
void set_constructor_kind(ConstructorKind constructor_kind) { m_constructor_kind = constructor_kind; }
@@ -75,7 +75,7 @@ private:
virtual bool is_function() const override { return true; }
Value m_bound_this;
Vector<Value> m_bound_arguments;
- Value m_home_object;
+ Object* m_home_object { nullptr };
ConstructorKind m_constructor_kind = ConstructorKind::Base;
ThisMode m_this_mode { ThisMode::Global };
bool m_has_simple_parameter_list { false };