diff options
author | davidot <davidot@serenityos.org> | 2021-12-30 14:13:20 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-12-30 15:29:33 +0100 |
commit | 676554d3f86d7c429f1969942190427666b5423e (patch) | |
tree | 6d598d4a12ab310167d7143d815962c0d299934c /Userland/Utilities | |
parent | dfaa6c910cda9fd49e681f10c7efbabed74ef0a6 (diff) | |
download | serenity-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/Utilities')
-rw-r--r-- | Userland/Utilities/js.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 480eaba48e..421b45e76b 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -1427,9 +1427,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) switch (mode) { case CompleteProperty: { Optional<JS::Value> maybe_value; - auto maybe_variable = vm->resolve_binding(variable_name, &global_environment); - if (vm->exception()) - break; + auto maybe_variable = TRY_OR_DISCARD(vm->resolve_binding(variable_name, &global_environment)); maybe_value = TRY_OR_DISCARD(maybe_variable.get_value(interpreter->global_object())); VERIFY(!maybe_value->is_empty()); |