summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2021-12-30 14:13:20 +0100
committerLinus Groh <mail@linusgroh.de>2021-12-30 15:29:33 +0100
commit676554d3f86d7c429f1969942190427666b5423e (patch)
tree6d598d4a12ab310167d7143d815962c0d299934c /Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
parentdfaa6c910cda9fd49e681f10c7efbabed74ef0a6 (diff)
downloadserenity-676554d3f86d7c429f1969942190427666b5423e.zip
LibJS: Convert resolve_binding() to ThrowCompletionOr
The spec has a note stating that resolve binding will always return a reference whose [[ReferencedName]] field is name. However this is not correct as the underlying method GetIdentifierReference may throw on env.HasBinding(name) thus it can throw. However, there are some scenarios where it cannot throw because the reference is known to exist in that case we use MUST with a comment.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
index 560f955d40..5f44bf8be3 100644
--- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp
@@ -441,9 +441,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::function_declaration_instantia
Environment* used_environment = has_duplicates ? nullptr : environment;
if constexpr (IsSame<FlyString const&, decltype(param)>) {
- Reference reference = vm.resolve_binding(param, used_environment);
- if (auto* exception = vm.exception())
- return throw_completion(exception->value());
+ Reference reference = TRY(vm.resolve_binding(param, used_environment));
// Here the difference from hasDuplicates is important
if (has_duplicates)
return reference.put_value(global_object(), argument_value);