summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBuffer.h4
-rw-r--r--Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.h2
4 files changed, 10 insertions, 8 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h
index 507a449bcd..94574ba837 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h
@@ -141,13 +141,13 @@ static ByteBuffer numeric_to_raw_bytes(GlobalObject& global_object, Value value,
swap(raw_bytes[i], raw_bytes[sizeof(UnderlyingBufferDataType) - 1 - i]);
};
if constexpr (IsSame<UnderlyingBufferDataType, float>) {
- float raw_value = value.to_double(global_object);
+ float raw_value = MUST(value.to_double(global_object));
ReadonlyBytes { &raw_value, sizeof(float) }.copy_to(raw_bytes);
flip_if_needed();
return raw_bytes;
}
if constexpr (IsSame<UnderlyingBufferDataType, double>) {
- double raw_value = value.to_double(global_object);
+ double raw_value = MUST(value.to_double(global_object));
ReadonlyBytes { &raw_value, sizeof(double) }.copy_to(raw_bytes);
flip_if_needed();
return raw_bytes;
diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp
index 6e5c4fe8ee..59308d9323 100644
--- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp
@@ -59,8 +59,10 @@ Value GeneratorObject::next_impl(VM& vm, GlobalObject& global_object, Optional<V
};
auto generated_continuation = [&](Value value) -> Bytecode::BasicBlock const* {
- if (value.is_object())
- return reinterpret_cast<Bytecode::BasicBlock const*>(static_cast<u64>(TRY_OR_DISCARD(value.as_object().get("continuation")).to_double(global_object)));
+ if (value.is_object()) {
+ auto number_value = TRY_OR_DISCARD(value.as_object().get("continuation"));
+ return reinterpret_cast<Bytecode::BasicBlock const*>(static_cast<u64>(TRY_OR_DISCARD(number_value.to_double(global_object))));
+ }
return nullptr;
};
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp
index 2fc03b5483..025b853c81 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Value.cpp
@@ -559,11 +559,11 @@ ThrowCompletionOr<u64> Value::to_bigint_uint64(GlobalObject& global_object) cons
return bigint->big_integer().to_u64();
}
-double Value::to_double(GlobalObject& global_object) const
+ThrowCompletionOr<double> Value::to_double(GlobalObject& global_object) const
{
auto number = to_number(global_object);
- if (global_object.vm().exception())
- return {};
+ if (auto* exception = global_object.vm().exception())
+ return throw_completion(exception->value());
return number.as_double();
}
diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h
index e155d34608..5cf3846741 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.h
+++ b/Userland/Libraries/LibJS/Runtime/Value.h
@@ -313,7 +313,7 @@ public:
ThrowCompletionOr<BigInt*> to_bigint(GlobalObject&) const;
ThrowCompletionOr<i64> to_bigint_int64(GlobalObject&) const;
ThrowCompletionOr<u64> to_bigint_uint64(GlobalObject&) const;
- double to_double(GlobalObject&) const;
+ ThrowCompletionOr<double> to_double(GlobalObject&) const;
StringOrSymbol to_property_key(GlobalObject&) const;
i32 to_i32(GlobalObject& global_object) const
{