mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02: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:
Notes:
sideshowbarker
2024-07-17 21:53:59 +09:00
Author: https://github.com/davidot Commit: https://github.com/SerenityOS/serenity/commit/676554d3f86 Pull-request: https://github.com/SerenityOS/serenity/pull/11503 Reviewed-by: https://github.com/linusg
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user