Verse: bug with nested race block

Summary

Sometimes in a ‘race’ block, the code for the ‘losing’ branch continues to execute after it should have been cancelled. This happens on a race block that is nested inside another race, and the whole sequence repeats on a loop.

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

Create a new device and paste the following code over the OnBegin function:

OnBegin<override>()<suspends>:void=
    loop:
        race:
            loop:
                race:
                    block:
                        Sleep(1.0)
                        Print("Done sleep 1.0")
                    block:
                        Sleep(2.0)
                        Print("Done sleep 2.0 - this should never happen!")
                Print("Done race between 1.0 and 2.0")
            block:
                Sleep(5.0)
                Print("Done sleep 5.0")
        Print("Done race between 5.0 and the others")

Compile, drag a copy of the device into the scene and launch the game.
Observe the output.

Expected Result

The “this should never happen” message should never appear, the output should be:
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 5.0
LogVerse: : Done race between 5.0 and the others
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 1.0

Observed Result

After the outer race has completed once and the sequence loops, the “this should never happen” message starts to appear, here is the output:
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 5.0
LogVerse: : Done race between 5.0 and the others
LogVerse: : Done sleep 1.0
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 2.0 - this should never happen!
LogVerse: : Done race between 1.0 and 2.0
LogVerse: : Done sleep 1.0

Platform(s)

Windows PC

Additional Notes

The bug doesn’t happen if the nested race is moved to its own function.

This may be related to this issue I have posted previously:

Yea this needs looking at the other post is july 2024