mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +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
15 changed files with 55 additions and 57 deletions
|
@ -942,7 +942,7 @@ static bool parse_and_run(JS::Interpreter& interpreter, StringView source, Strin
|
|||
auto result = bytecode_interpreter.run(executable);
|
||||
// Since all the error handling code uses vm.exception() we just rethrow any exception we got here.
|
||||
if (result.is_error())
|
||||
vm->throw_exception(interpreter.global_object(), result.throw_completion().value());
|
||||
vm->throw_exception(interpreter.global_object(), *result.throw_completion().value());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue