1. Create 2 scripts "BugHolder" and "Bug"
public class BugHolder : UdonSharpBehaviour
{
public Bug[] list;
void Start()
{
var result = GetBugFromList(0).PerformBug(this);
Debug.Log("Result: " + result);
}
public Bug GetBugFromList(int i)
{
return list[i];
}
}
public class Bug : UdonSharpBehaviour
{
public int id;
public int PerformBug(BugHolder h)
{
h.GetBugFromList(1);
Debug.Log("Returning ID: " + id);
return id;
}
}
  1. Attach the bug holder and 2 bug components put them into the list and give them unique non-zero ids.
  2. Press play. The printed result will be incorrect.
This happens because Udon does not support return values, so it stores the return value in a variable (let's say {FunctionName}_result). Then when the code is compiled it gets turned into something like this (pseudocode):
void Start() {
this.GetBugFromList(0)
this.GetBugFromList_result.PerformBug(this)
var result = this.GetBugFromList_result.PerformBug_result
}
The issue is that calling PerformBug calls GetBugFromList which overrides the value of the GetBugFromList_result variable and then the next statement gets the wrong result.
A potential fix could be to have the compiler create a local variable for you storing the result of the function.
This bug was very difficult to debug.