Bug with passing enum values from For Each loop

I’ve attached a sample project to demonstrate the bug. The project is for 4.17, however the bug exists in all versions I’ve tried.

Open the sample project, then open the Actor blueprint and refer to the comments in the Check Enums function for steps to follow. Finally refer to the comment in the Get Enums function for more details.

Hello wilberolive,

After running a few tests with the foreach"Enum", it appears to be working as intended. Could you elaborate further on what issue it is exactly that you are seeing?

Hi Rudy, did you try out the attached sample project and follow the steps in it?

The exact issue is difficult to explain and is best shown in a simple demonstration as per the comments in the attach sample project.

Hi Rudy, any update on this yet?

Basically, the issue is that when an enum value is passed from a foreach loop to a function (with a bool return pin) and then processed in a switch statement, the function does not return the correct result on the bool pin. The bug requires this very specific set up in order to trigger it, so it would be easy to miss if you don’t use the attached sample that is set up precisely to demonstrate the bug.

I’m not sure if it is actually for the foreach loop that is the root cause of the problem, but that is where it appears to be originating from. If the foreach loop in the attached sample is replaced with a series of IF nodes instead then the bug disappears.

I also tried updating the sample to the latest v4.18 preview 3 and the bug is still there.

Here is an updated sample project to the latest v4.18 Preview 4.

Hello wilberolive,

After taking a second look at the project and reading over you explanation. This is working as intended.

Explanation:

Your function “Check Enum” has two execution pins that are not connected to anything. However, the function must return something when called. This means that when anything other than the first execution pin is used, the return value does not get updated. If the return value is never updated, it will simply return the last value it was given.

I hope that this information helps.

Make it a great day

Hi Rudy,

Thanks for getting back to me.

However I don’t think you quite understand what I’m trying to explain. In fact your explanation further reinforces to me that there is a bug here. You may have also missed an important comment in the project about a foreach loop vs a series or branch nodes which supports the claim that there is a bug here.

Please take a look at this updated sample, which further demonstrate these issues and proves that there is in fact a bug that needs to be fixed. Take a look at the comment in the FixedActor (inside the CheckEnum function) and compare this with the comment in the BrokenActor. Also be sure to check the comment in GameActor, which shows why this is such a serious bug.

I have taken a look at the project provided, however as stated previously this is working as intended. Simply put the return node is used to update the output for the function. If a return node is not called it keeps state and the output value will not update. The reason the function using branches works (as you would expect) is because each call is a separate instance of the function. The reason some of the instances return false by default is because the return node has never been called (this is why it defaults back to the value given to that data type by default in the engine).

Generally speaking open execution pins as seen in this example are not considered recommended workflow.