diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-10-17 23:44:25 +0300 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2021-10-18 08:01:38 +0300 |
commit | 627b1205ced61ace766bff9b486f2718cd02c26a (patch) | |
tree | 696e885049d24552402ad8948ec30c5296d50d1d /Userland/Libraries | |
parent | cc94bba5c0461eebeb13a063c844330b0234e0bd (diff) | |
download | serenity-627b1205ced61ace766bff9b486f2718cd02c26a.zip |
LibJS: Convert to_i16() to ThrowCompletionOr
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ArrayBuffer.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.h | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h index b980f294ca..dd860f7b2a 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h @@ -171,7 +171,7 @@ static ByteBuffer numeric_to_raw_bytes(GlobalObject& global_object, Value value, if constexpr (sizeof(UnderlyingBufferDataType) == 4) int_value = MUST(value.to_i32(global_object)); else if constexpr (sizeof(UnderlyingBufferDataType) == 2) - int_value = value.to_i16(global_object); + int_value = MUST(value.to_i16(global_object)); else int_value = value.to_i8(global_object); } else { diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 148f6647e8..b33d0ad1f0 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -607,9 +607,9 @@ ThrowCompletionOr<u32> Value::to_u32(GlobalObject& global_object) const } // 7.1.8 ToInt16 ( argument ), https://tc39.es/ecma262/#sec-toint16 -i16 Value::to_i16(GlobalObject& global_object) const +ThrowCompletionOr<i16> Value::to_i16(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 abs = fabs(value); diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 296bb0eab0..39ea340698 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -317,7 +317,7 @@ public: ThrowCompletionOr<StringOrSymbol> to_property_key(GlobalObject&) const; ThrowCompletionOr<i32> to_i32(GlobalObject& global_object) const; ThrowCompletionOr<u32> to_u32(GlobalObject&) const; - i16 to_i16(GlobalObject&) const; + ThrowCompletionOr<i16> to_i16(GlobalObject&) const; u16 to_u16(GlobalObject&) const; i8 to_i8(GlobalObject&) const; u8 to_u8(GlobalObject&) const; |