I've run into an issue with do-while loops in UdonSharp. When using a
continue
statement, it restarts the loop without checking the loop's condition. Below is a code snippet demonstrating the issue. An UdonGraph demonstration is not included, as it doesn't seem to have a do-while node as an option. Let me know if any further information from me would be useful, such as the resulting assembly or disassembly.
Version info:
  • Unity 2022.3.22f1
  • VRChat SDK - Base 3.10.2
  • VRChat SDK - Worlds 3.10.2
DoWhileContinue.cs:
void Start()
{
var a = 0;
var b = 0;
do
{
Debug.Log($"{a}, {b++}");
continue;
} while (a++ < 3 && b < 3);
Debug.Log($"Done :)");
}
Output when executed as C#:
0, 0
1, 1
2, 2
Done :)
Output when executed as U#:
0, 0
0, 1
0, 2
0, 3
...<snip>...
0, 119526
0, 119527
[UdonSharp] Assets/DoWhileContinueUSharp.cs(14,22): Udon runtime exception detected!
The VM encountered an error!
Program execution time exceeded max VM time of 10.0 seconds. You may want to check for infinite loops/recursion.