View Single Post
03/24/15, 04:27 PM   #1
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
table.sort (parameter is nil)?

What could cause the parameter of a function, used in a table.sort(..., function), to have a nil parameter?

In one of my sorts in TextureIt I just encountered an error "Attempt to index a nil value" and I'm not sure how it is happening. It is random, it isn't tied to any specific search. For example I've just been searching "open" & "close" (without quotes). I just keep reloading the ui and doing the searches, sometimes both searches work, sometimes the second parameter passed to the sort function is nil.

I tried saving a reference to the table I'm sorting & examining it with /zgoo whenever the error occurs, but it looks ok to me?

Code that calls the sort & sort code:
Warning: Spoiler


I'm not sure if this part has anything to do with it, but I'll include it anyways. This is where the searchResults table gets populated. I pass in a destination table (searchResults) to save the matches into because of the recursion. So I don't have to copy the returned results each time the recursion happens.
Warning: Spoiler


Anyone have any ideas why table.sort would pass in a nil parameter to my sort function?
  Reply With Quote