# Is it not possible to return from a loop expression within a failable function?

**URL:** <https://forums.unrealengine.com/t/is-it-not-possible-to-return-from-a-loop-expression-within-a-failable-function/1842120>\
**Category:** Programming & Scripting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [May 6, 2024, 1:42am UTC](https://forums.unrealengine.com/t/is-it-not-possible-to-return-from-a-loop-expression-within-a-failable-function/1842120 "2024-05-06T01:42:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![t.tutiya](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/t.tutiya/32/924637_2.png) [@t.tutiya](https://forums.unrealengine.com/u/t.tutiya)\
**Post date:** [May 6, 2024, 1:42am UTC](https://forums.unrealengine.com/t/is-it-not-possible-to-return-from-a-loop-expression-within-a-failable-function/1842120/1 "2024-05-06T01:42:35Z")

</div>

The following code will result in an error `Explicit return out of a failure context is not allowed`

```auto
Test02(X:[]int)<transacts><decides>:void = 
    for(Y:X):
        return
    false?

```

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/c/c/1ccaf4112f10f3c199e5b2955c620b9782a63001.png)

Is it not possible to return from a loop expression within a failable function?  
If so, why is that?

---

<div class="post-metadata">

**Author:** ![t.tutiya](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/t.tutiya/32/924637_2.png) [@t.tutiya](https://forums.unrealengine.com/u/t.tutiya)\
**Post date:** [May 6, 2024, 2:27am UTC](https://forums.unrealengine.com/t/is-it-not-possible-to-return-from-a-loop-expression-within-a-failable-function/1842120/2 "2024-05-06T02:27:09Z")

</div>

More Info.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/4/3/b43cbaac56832e382afa398e5b7c08a3ca75c0ee.png)  
I think it is just a bug.

---

<div class="post-metadata">

**Author:** ![t.tutiya](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/t.tutiya/32/924637_2.png) [@t.tutiya](https://forums.unrealengine.com/u/t.tutiya)\
**Post date:** [May 6, 2024, 5:02am UTC](https://forums.unrealengine.com/t/is-it-not-possible-to-return-from-a-loop-expression-within-a-failable-function/1842120/3 "2024-05-06T05:02:46Z")

</div>

Sorry, the issue has already been mentioned.

> [@Has anyone successfully written a failable function in Verse?](https://forums.unrealengine.com/t/has-anyone-successfully-written-a-failable-function-in-verse/1160379/3):
>
> You can’t return explicitly from a failable context. So that stops you from using return Y false? always fails, without returning any value. However, right now the compiler still wants to see the function return a value of its return type (int) since it can’t infer that anything after false? won’t execute. You could wrap this in an option: Find(X:[]int, F(:int)\<transacts\>\<decides\>:void)\<transacts\>\<decides\>:int = var RetInt:?int = false for (Y:X, F[Y], not RetInt?): set RetIn…

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [June 5, 2024, 5:03am UTC](https://forums.unrealengine.com/t/is-it-not-possible-to-return-from-a-loop-expression-within-a-failable-function/1842120/4 "2024-06-05T05:03:24Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
