mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:08:10 +00:00
LibJS: Add a MUST() macro, like TRY() but for the spec's !
shortcut
This commit is contained in:
parent
8f722302d9
commit
7cd3f7de61
1 changed files with 13 additions and 0 deletions
|
@ -26,6 +26,19 @@ namespace JS {
|
|||
_temporary_result.release_value(); \
|
||||
})
|
||||
|
||||
// MUST() is to the spec's `!` what TRY() is to `?`.
|
||||
// https://tc39.es/ecma262/#sec-returnifabrupt-shorthands
|
||||
#define MUST(expression) \
|
||||
({ \
|
||||
auto _temporary_result = (expression); \
|
||||
VERIFY(!_temporary_result.is_error()); \
|
||||
/* The return value of "! Something()" is commonly */ \
|
||||
/* ignored, so we assign to a temporary variable here */ \
|
||||
/* to avoid having to (void) all the things. */ \
|
||||
auto _temporary_value = _temporary_result.release_value(); \
|
||||
move(_temporary_value); \
|
||||
})
|
||||
|
||||
// 6.2.3 The Completion Record Specification Type, https://tc39.es/ecma262/#sec-completion-record-specification-type
|
||||
class [[nodiscard]] Completion {
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue