mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:18:13 +00:00
AK+Everywhere: Disallow returning a reference from a fallible expression
This will silently make a copy. Rather than masking this behavior, let's explicitly disallow it.
This commit is contained in:
parent
3de75f6436
commit
afc0e461e1
11 changed files with 86 additions and 54 deletions
|
@ -31,12 +31,14 @@
|
|||
|
||||
namespace Web::WebDriver {
|
||||
|
||||
#define TRY_OR_JS_ERROR(expression) \
|
||||
({ \
|
||||
auto _temporary_result = (expression); \
|
||||
if (_temporary_result.is_error()) [[unlikely]] \
|
||||
return ExecuteScriptResultType::JavaScriptError; \
|
||||
_temporary_result.release_value(); \
|
||||
#define TRY_OR_JS_ERROR(expression) \
|
||||
({ \
|
||||
auto _temporary_result = (expression); \
|
||||
if (_temporary_result.is_error()) [[unlikely]] \
|
||||
return ExecuteScriptResultType::JavaScriptError; \
|
||||
static_assert(!IsLvalueReference<decltype(_temporary_result.release_value())>, \
|
||||
"Do not return a reference from a fallible expression"); \
|
||||
_temporary_result.release_value(); \
|
||||
})
|
||||
|
||||
static ErrorOr<JsonValue, ExecuteScriptResultType> internal_json_clone_algorithm(JS::Realm&, JS::Value, HashTable<JS::Object*>& seen);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue