Due to an error in my program I appended an empty element to a table. As a result, the integer indexes (or the result of TableItems) are no longer correct. I am not sure if I should call this a bug.
SamuraiCrow wrote: ↑Sat Dec 31, 2022 7:06 am
Probably not a bug because assigning NIL to a table entry is the legal way to mark it as empty.
But look at the third to last and the last line. An element has been added to the end of the table, and then the last element of the table is accessed. This should not fail, I think.
Maybe it gets messed, because it's not allowed to remove items from an optimized list (CreateList()) by anything else but RemoveItem(). So removing an item by setting it to Nil is against the guideline.
And in any case when one item (index 3) has been removed by setting it to Nil but index counter probably still increased (with an optimized list? Doesn't do it with a "normal" list?), there's four items left, and the last line tries to print the item at index 3 then...
Not really a bug because you're using TableItems() with an optimized list which is not really supported. For optimized lists you should always use ListItems() to get the number of items. Using TableItems() for lists doesn't make sense anyway because a list shouldn't contain anything else than just a linear array of 0..n items.
Flinx wrote: ↑Tue Jan 03, 2023 4:25 pm
Thank you for the advice. Perhaps this should be said a little more explicitly in the manual.
Well, I've just changed TableItems() to behave like ListItems() now in case the table passed was instantiated by CreateList(). That's probably the most convenient solution.