1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 21:58:10 +00:00

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.
This commit is contained in:
davidot 2021-12-30 14:13:20 +01:00 committed by Linus Groh
parent dfaa6c910c
commit 676554d3f8
8 changed files with 44 additions and 42 deletions

View file

@ -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);