# ReturnIfAbrupt Macro

**URL:** <https://es.discourse.group/t/returnifabrupt-macro/2446>\
**Category:** I have questions\
**Created:** [October 13, 2025, 5:52pm UTC](https://es.discourse.group/t/returnifabrupt-macro/2446 "2025-10-13T17:52:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaurav-rk9](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/gaurav-rk9/32/2546_2.png) [@gaurav-rk9](https://es.discourse.group/u/gaurav-rk9)\
**Post date:** [October 13, 2025, 5:52pm UTC](https://es.discourse.group/t/returnifabrupt-macro/2446/1 "2025-10-13T17:52:34Z")

</div>

The spec ( [ECMAScript® 2026 Language&nbsp;Specification](https://tc39.es/ecma262/#sec-returnifabrupt) ) says:  
Algorithms steps that say or are otherwise equivalent to:

1. ReturnIfAbrupt(AbstractOperation()).

mean the same thing as:

1. Let hygienicTemp be AbstractOperation().

2. Assert: hygienicTemp is a Completion Record.

3. If hygienicTemp is an abrupt completion, return Completion(hygienicTemp).

4. Else, set hygienicTemp to hygienicTemp.[[Value]].

Where hygienicTemp is ephemeral and visible only in the steps pertaining to ReturnIfAbrupt.

But it is unclear from the spec what would happen when when writes  
Let val be ReturnIfAbrupt(AbstractOperation()), when the result of AbstractOperation() is not an abrubt completion.  
should val be result of AbstractOperation() or AbstractOperation().[[value]] or something else?

The following section defines what “1. Let result be AbstractOperation(ReturnIfAbrupt(argument)).” means, but in most cases in spec, I see “let result be !AbstractOperation()” which is not same as this.

Also what is the difference in “1. ReturnIfAbrupt(argument).” and “1. ReturnIfAbrupt(AbstractOperation()).” that they needed to be specified seperately.

Seems like I am missing some fundamental stuff here, so would appreciate any answers. Thanks!

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [October 13, 2025, 6:05pm UTC](https://es.discourse.group/t/returnifabrupt-macro/2446/2 "2025-10-13T18:05:09Z")

</div>

They’re specified separately to be explicit and thorough.

If the argument - whether it’s inline or returned from an AO - is a non-abrupt completion, it is replaced with the [[value]] field of the completion.

---

<div class="post-metadata">

**Author:** ![gaurav-rk9](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/gaurav-rk9/32/2546_2.png) [@gaurav-rk9](https://es.discourse.group/u/gaurav-rk9)\
**Post date:** [October 13, 2025, 6:17pm UTC](https://es.discourse.group/t/returnifabrupt-macro/2446/3 "2025-10-13T18:17:50Z")

</div>

> [@ljharb](#):
>
> They’re specified separately to be explicit and thorough.

So, to clarify, you are saying that there is no fundamental difference in both the statement expansions, it is just for additional clarity. If the second definition hadn’t been there, it would still have the same meaning?

> [@ljharb](#):
>
> it is replaced with the [[value]] field of the completion.

This brings another question to my mind  
what is the purpose of 4th step in “1. [ReturnIfAbrupt](#sec-returnifabrupt)(AbstractOperation()).” expansion. That is “4. Else, set hygienicTemp to hygienicTemp.[[Value]].”. If hygienicTemp is ephemeral, what is the point of setting it to something?

---

<div class="post-metadata">

**Author:** ![bakkot](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/bakkot/32/22_2.png) [@bakkot](https://es.discourse.group/u/bakkot)\
**Post date:** [October 13, 2025, 6:26pm UTC](https://es.discourse.group/t/returnifabrupt-macro/2446/4 "2025-10-13T18:26:43Z")

</div>

Yeah, this section has long needed rewriting, sorry about that. I recommend ignoring it entirely and instead reading [this comment](https://github.com/tc39/ecma262/pull/1573#issuecomment-3084926665). It makes no mention of `ReturnIfAbrupt` because the intention is to define the `!` and `?` macros directly, and to no longer use `ReturnIfAbrupt` (as of relatively recently its only remaining use is to define the `!` and `?` macros).

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [October 13, 2025, 6:32pm UTC](https://es.discourse.group/t/returnifabrupt-macro/2446/5 "2025-10-13T18:32:24Z")

</div>

I'm not sure if the editors would agree that they have the same meaning, but to me personally, yes, they're interchangeable.

If it's not set to something then the [[Value]] can't be reused in the next step. It's a macro - it may be a helpful exercise to manually edit the spec text for a few cases to expand the macro.
