1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:57:35 +00:00

LibWeb: Ensure dom_exception_to_throw_completion() always takes a VM

The combination of template + auto&& parameter + constexpr if statements
allowed one caller to pass in a GlobalObject, without the compiler
complaining.
This commit is contained in:
Linus Groh 2022-10-27 23:23:03 +01:00
parent 9cda0b2b2c
commit de3e6cc75c
2 changed files with 5 additions and 6 deletions

View file

@ -57,7 +57,7 @@ struct ExtractExceptionOrValueType<WebIDL::ExceptionOr<void>> {
using Type = JS::Value;
};
ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(auto&& vm, auto&& exception)
ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(JS::VM& vm, auto&& exception)
{
return exception.visit(
[&](WebIDL::SimpleException const& exception) {
@ -91,7 +91,7 @@ using ExtractExceptionOrValueType = typename Detail::ExtractExceptionOrValueType
// ExceptionOr<T>: JS::ThrowCompletionOr<T>
// T: JS::ThrowCompletionOr<T>
template<typename F, typename T = decltype(declval<F>()()), typename Ret = Conditional<!IsExceptionOr<T> && !IsVoid<T> && !IsThrowCompletionOr<T>, T, ExtractExceptionOrValueType<T>>>
JS::ThrowCompletionOr<Ret> throw_dom_exception_if_needed(auto&& vm, F&& fn)
JS::ThrowCompletionOr<Ret> throw_dom_exception_if_needed(JS::VM& vm, F&& fn)
{
if constexpr (IsExceptionOr<T>) {
auto&& result = fn();