diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h index d850ab8472..af6044f7b4 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h @@ -180,7 +180,7 @@ static ByteBuffer numeric_to_raw_bytes(GlobalObject& global_object, Value value, else if constexpr (sizeof(UnderlyingBufferDataType) == 2) int_value = MUST(value.to_u16(global_object)); else if constexpr (!IsSame) - int_value = value.to_u8(global_object); + int_value = MUST(value.to_u8(global_object)); else int_value = value.to_u8_clamp(global_object); } diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 4d3a5087b4..3738464b4e 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -656,9 +656,9 @@ ThrowCompletionOr Value::to_i8(GlobalObject& global_object) const } // 7.1.11 ToUint8 ( argument ), https://tc39.es/ecma262/#sec-touint8 -u8 Value::to_u8(GlobalObject& global_object) const +ThrowCompletionOr Value::to_u8(GlobalObject& global_object) const { - double value = TRY_OR_DISCARD(to_number(global_object)).as_double(); + double value = TRY(to_number(global_object)).as_double(); if (!isfinite(value) || value == 0) return 0; auto int_val = floor(fabs(value)); diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 727c65c82a..8bd7bfad55 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -320,7 +320,7 @@ public: ThrowCompletionOr to_i16(GlobalObject&) const; ThrowCompletionOr to_u16(GlobalObject&) const; ThrowCompletionOr to_i8(GlobalObject&) const; - u8 to_u8(GlobalObject&) const; + ThrowCompletionOr to_u8(GlobalObject&) const; u8 to_u8_clamp(GlobalObject&) const; size_t to_length(GlobalObject&) const; size_t to_index(GlobalObject&) const;