Table unpack is not available in either Lua 5.1 nor LuaJIT, yet it's used as a fallback for unpack. This is not an error on itself, but is listed as an error by Luacheck. An alternative solution would be to remove this line entirely
This issue was related to Lua not handling coroutines iterators right, the function being recursive generated multiple coroutine iterators and they didn't resume right. The solution is to make the first loop non-recursive and create a secondary loop where the recursive function is called.