mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 14:05:09 +00:00
LibJS: Allow function calls with missing arguments
We were interpreting "undefined" as a variable lookup failure in some cases and throwing a ReferenceError exception instead of treating it as the valid value "undefined". This patch wraps the result of variable lookup in Optional<>, which allows us to only throw ReferenceError when lookup actually fails.
This commit is contained in:
parent
04ced9e24a
commit
c60dc84a33
7 changed files with 45 additions and 10 deletions
|
@ -63,7 +63,7 @@ bool Object::put_own_property(Object& this_object, const FlyString& property_nam
|
|||
return true;
|
||||
}
|
||||
|
||||
Value Object::get(const FlyString& property_name) const
|
||||
Optional<Value> Object::get(const FlyString& property_name) const
|
||||
{
|
||||
const Object* object = this;
|
||||
while (object) {
|
||||
|
@ -72,7 +72,7 @@ Value Object::get(const FlyString& property_name) const
|
|||
return value.value();
|
||||
object = object->prototype();
|
||||
}
|
||||
return js_undefined();
|
||||
return {};
|
||||
}
|
||||
|
||||
void Object::put(const FlyString& property_name, Value value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue