summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Interpreter.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-27 12:54:18 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-27 12:56:05 +0100
commitc60dc84a333a85bd859d284cea72b9c02682a392 (patch)
tree97cd62730ea66b3ad4f07813cde51ea014cba23f /Libraries/LibJS/Interpreter.h
parent04ced9e24a7015c867060478c3418cde81f93214 (diff)
downloadserenity-c60dc84a333a85bd859d284cea72b9c02682a392.zip
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.
Diffstat (limited to 'Libraries/LibJS/Interpreter.h')
-rw-r--r--Libraries/LibJS/Interpreter.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/Libraries/LibJS/Interpreter.h b/Libraries/LibJS/Interpreter.h
index fe806f9a4f..f65ae60386 100644
--- a/Libraries/LibJS/Interpreter.h
+++ b/Libraries/LibJS/Interpreter.h
@@ -79,7 +79,7 @@ public:
void unwind(ScopeType type) { m_unwind_until = type; }
- Value get_variable(const FlyString& name);
+ Optional<Value> get_variable(const FlyString& name);
void set_variable(const FlyString& name, Value, bool first_assignment = false);
void declare_variable(const FlyString& name, DeclarationType);