And how exactly I am supposed to do this job? E.g., how can I test
that an array t coming my way from someone else's library has no
holes?
Two options:
1: Don't bother. It's the caller's responsibility to obey your API
requirements.
2: Give your tables a metatable that keeps track of the invariants you
require, if they don't match the ones provided by Lua.