Array of structs breaks when adding new structs.
-
I have a program that looks something like this:
var segments = [] segments[0] = [ [.a = {200, 300}, .b = {240, 100}], [.a = {240, 100}, .b = {540, 100}], [.a = {540, 100}, .b = {240, 100}], // ..and a lot more statements like these... ] // Then a little later I do this: segments[0][len(segments[0])] = [.a = {840, 100}, .b = {620, 400}] print(len(segments[0])) update() sleep(3) // That seems to be working. But then I do it once more: segments[0][len(segments[0])] = [.a = {140, 600}, .b = {320, 120}] print(len(segments[0])) update() sleep(3) // This time the program crashes on the last print statement!
This is the error that happens:
LINE: 43 FUNCTION: len Unrecognised type: 1146106016
Interestingly, if I remove some of the segments from the initial segment definition I do not get the error.
My example program for this has been shared and submitted.
ID: X6473MND5C
-
If someone knows a workaround, I would very much appreciate it.
-
Possibly related to this:
https://fuzearena.com/forum/topic/1349/len-is-broken-in-some-circumstances-with-2-15 -
Why not just keep track of the length in a seperate variable? Then you don’t have to use len()...
-
It seems broken in other ways too. For instance passing the array to str() yields a similar error.
-
As a workaround, I created a temp array, copied the contents of segments[0] using a loop, added the new segments, and finally copied the temp array back to segments[0] again.
-
Thanks for the report- A fix is in the works!