I’ve come across an issue where I have a local structure variable that contains empty array children. In a loop, I initialise instances of this structure and then add them to a scene array.
What I’ve noticed is that if I inspect these children arrays in the debugger, they are represented as numbers, instead of arrays:
Adding items to these arrays converts them back to arrays:
The issue I discovered is that if I accidentally try to access the empty array via an invalid index, the engine will set the number value to the index and now the array length is reported as 1.
Note that the above does not happen if, instead of the local Struct variable, I use the TestStruct structure variable declared at the scene level:
No doubt that one should be checking that the array index is valid, but the behaviour of the engine here is definitely unexpected. I had a bug in my code where I was effectively accessing index -1 of an empty array but instead of throwing some sort of error or returning a null value the engine quietly added an item to the array, which made it much harder to track down and identify the bug.
I think the fact that the engine is reporting the array as a number indicates a issue that warrants investigation.
Here is the full event sheet:
The forum doesn’t allow me to upload zip files so I can’t share the project.














