Quote: "Why is this,"
There is some behaviour of arrays that I can't do too much about, and one of these is the fact that when you enlarge an array in any way it will allocate a new array, copy the old stuff over to the new, then return the old array memory to be reused at a later point.
It's also worth noting that arrays are simply glorified pointers to array-related data
With that out of the way, let's analyse what's going on.
First relevant line, which makes foo() and bar() represent the same array in memory:
link array foo(), get arrayPtr(bar())
Next relevant line:
array insert at bottom foo()
This allocates a new array (as explained above), and creates an entirely new array. At this point foo() represents an array, and bar() points to freed memory (ie, it's not pointing to an array any more).
BTW, when you insert into an array, the first newly inserted item becomes the current item, so using ARRAY INDEX TO BOTTOM is not needed in your code.
Next relevant line:
Accessing random memory as if it were an array ... basically, you're lucky that a subscript error was what you got. The alternative would be that it works, but you overwrite some random memory which could be anything from other arrays, strings, loaded sounds/textures/objects etc and have corruption that you wouldn't be able to explain.
Quote: "and are there any workarounds?"
Let me know what you are trying to accomplish and I might be able to suggest an alternative.