mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibJS: Return Optional<T> from Completion::{value,target}(), not T
In the end this is a nicer API than having separate has_{value,target}() and having to check those first, and then making another Optional from the unwrapped value: completion.has_value() ? completion.value() : Optional<Value> {} // ^^^^^^^^^^^^^^^^^^ // Implicit creation of non-empty Optional<Value> This way we need to unwrap the optional ourselves, but can easily pass it to something else as well. This is in anticipation of the AST using completions :^)
This commit is contained in:
parent
b39aede8fe
commit
85f0fc2b83
Notes:
sideshowbarker
2024-07-17 21:44:52 +09:00
Author: https://github.com/linusg
Commit: 85f0fc2b83
Pull-request: https://github.com/SerenityOS/serenity/pull/11513
Reviewed-by: https://github.com/davidot ✅
15 changed files with 55 additions and 57 deletions
|
@ -361,7 +361,7 @@ ThrowCompletionOr<void> VM::iterator_binding_initialization(BindingPattern const
|
|||
auto next_object_or_error = iterator_next(*iterator);
|
||||
if (next_object_or_error.is_throw_completion()) {
|
||||
iterator_done = true;
|
||||
return JS::throw_completion(next_object_or_error.release_error().value());
|
||||
return JS::throw_completion(*next_object_or_error.release_error().value());
|
||||
}
|
||||
auto* next_object = next_object_or_error.release_value();
|
||||
|
||||
|
@ -380,7 +380,7 @@ ThrowCompletionOr<void> VM::iterator_binding_initialization(BindingPattern const
|
|||
auto next_object_or_error = iterator_next(*iterator);
|
||||
if (next_object_or_error.is_throw_completion()) {
|
||||
iterator_done = true;
|
||||
return JS::throw_completion(next_object_or_error.release_error().value());
|
||||
return JS::throw_completion(*next_object_or_error.release_error().value());
|
||||
}
|
||||
auto* next_object = next_object_or_error.release_value();
|
||||
|
||||
|
@ -392,7 +392,7 @@ ThrowCompletionOr<void> VM::iterator_binding_initialization(BindingPattern const
|
|||
auto value_or_error = next_object->get(names.value);
|
||||
if (value_or_error.is_throw_completion()) {
|
||||
iterator_done = true;
|
||||
return JS::throw_completion(value_or_error.release_error().value());
|
||||
return JS::throw_completion(*value_or_error.release_error().value());
|
||||
}
|
||||
value = value_or_error.release_value();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue