1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 02:13:56 +09: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:
Andreas Kling 2020-03-27 12:54:18 +01:00
parent 04ced9e24a
commit c60dc84a33
Notes: sideshowbarker 2024-07-19 08:06:31 +09:00
7 changed files with 45 additions and 10 deletions

View file

@ -142,7 +142,7 @@ void Interpreter::set_variable(const FlyString& name, Value value, bool first_as
global_object().put(move(name), move(value));
}
Value Interpreter::get_variable(const FlyString& name)
Optional<Value> Interpreter::get_variable(const FlyString& name)
{
for (ssize_t i = m_scope_stack.size() - 1; i >= 0; --i) {
auto& scope = m_scope_stack.at(i);