1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:37:45 +00:00

LibJS: Use empty value for Reference unresolvable state, not undefined

This fixes an issue where `undefined.foo = "bar"` would throw a
ReferenceError instead of a TypeError as undefined was also used for
truly unresolvable references (e.g. `foo() = "bar"`). I also made the
various error messages here a bit nicer, just "primitive value" is not
very helpful.
This commit is contained in:
Linus Groh 2021-04-02 21:00:37 +02:00 committed by Andreas Kling
parent d6cffb82a2
commit e875513ff7
4 changed files with 39 additions and 15 deletions

View file

@ -64,7 +64,7 @@ public:
const PropertyName& name() const { return m_name; }
bool is_strict() const { return m_strict; }
bool is_unresolvable() const { return m_base.is_undefined(); }
bool is_unresolvable() const { return m_base.is_empty(); }
bool is_property() const
{
return m_base.is_object() || has_primitive_base();
@ -91,7 +91,7 @@ public:
private:
void throw_reference_error(GlobalObject&);
Value m_base { js_undefined() };
Value m_base;
PropertyName m_name;
bool m_strict { false };
bool m_local_variable { false };