mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
js: Make more use of Value::as_if
This commit is contained in:
Notes:
github-actions[bot]
2026-02-28 15:26:00 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/0334a6b341c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8216 Reviewed-by: https://github.com/trflynn89 ✅
@@ -245,9 +245,8 @@ static ErrorOr<bool> parse_and_run(JS::Realm& realm, StringView source, StringVi
|
||||
warnln("Uncaught exception: ");
|
||||
TRY(print(thrown_value, PrintTarget::StandardError));
|
||||
|
||||
if (!thrown_value.is_object() || !is<JS::Error>(thrown_value.as_object()))
|
||||
return {};
|
||||
warnln("{}", static_cast<JS::Error const&>(thrown_value.as_object()).stack_string(JS::CompactTraceback::Yes));
|
||||
if (auto error = thrown_value.template as_if<JS::Error>())
|
||||
warnln("{}", error->stack_string(JS::CompactTraceback::Yes));
|
||||
return {};
|
||||
};
|
||||
|
||||
@@ -782,12 +781,10 @@ static ErrorOr<int> run_repl(bool gc_on_every_allocation, bool syntax_highlight)
|
||||
auto variable = value_or_error.value();
|
||||
VERIFY(!variable.is_special_empty_value());
|
||||
|
||||
if (!variable.is_object())
|
||||
break;
|
||||
|
||||
auto const object = MUST(variable.to_object(*g_vm));
|
||||
auto const& shape = object->shape();
|
||||
list_all_properties(shape, property_name);
|
||||
if (auto object = variable.template as_if<JS::Object>()) {
|
||||
auto const& shape = object->shape();
|
||||
list_all_properties(shape, property_name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CompleteVariable: {
|
||||
|
||||
Reference in New Issue
Block a user