Array "Add" node compiles and runs without "new item" input connected

image

The array “Add” node will compile and execute without anything connected to the “new item” input pin. I don’t know if it’s populating the array with null or what but it is doing something to the array. In another part of my code the array items returned as “invalid” and it led to inexplicable errors in the part of my code meant to clean up said invalid array items. I tried to “get” and printstring the name of the items after adding like this but it would just print nothing.

I lost hours to this after accidentally leaving this pin empty, as the engine gave no compilation errors or warnings and the resulting behavior was seemingly impossible to make sense of.

This should produce a warning or error at compilation time instead of quietly behaving badly.

This would create an empty entry inside your array, basically the same thing that you get if you add empty entries to the array variables directly in the variable detail panel. Those null reference will lead to some error if you tried to call things on them, since there is nothing to address.
Also, since there isn’t anything then you can’t print the referenced object name, that’s why you should print something specific when the array element is invalid.
Two advices:

  • Wrap the add node for your array inside a function that checks that the reference is valid before adding it in the array
  • Always check that your entries are valid when calling stuff on them