mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02: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:
Notes:
sideshowbarker
2024-07-17 21:44:52 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/85f0fc2b83a Pull-request: https://github.com/SerenityOS/serenity/pull/11513 Reviewed-by: https://github.com/davidot ✅
@@ -41,7 +41,7 @@ ThrowCompletionOr<Value> AsyncFunctionDriverWrapper::react_to_async_task_complet
|
||||
vm.clear_exception();
|
||||
vm.stop_unwind();
|
||||
auto promise = Promise::create(global_object);
|
||||
promise->reject(generator_result.throw_completion().value());
|
||||
promise->reject(*generator_result.throw_completion().value());
|
||||
return promise;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user