Hi all,
When table.unpack encounters an error (such as the above or "attempt to get length of a number value"), it doesn't add/push the source and line number of the error.
Compare the output of the following two functions producing an error at runtime:
> print( pcall(function() table.unpack(nil) end) )
false attempt to get length of a nil value
Expected:
> print( pcall(function() string.gsub(nil) end) )
false stdin:1: bad argument #1 to 'gsub' (string expected, got nil)
Lua 5.2.4: unpack adds error source
Lua 5.3.6 and above, including 5.5.0: table.unpack doesn't add error source
A host application (proprietary, with Lua 5.3), that I'm working with, struggles to produce an error message at all in case of table.unpack(123) (no line number or error message). Yet other errors show up fine in the logs.
If I read it correctly, 5.2's unpack has had an explicit luaL_checktype(L, 1, LUA_TTABLE); ?
https://github.com/lua/lua/blob/4324904b60db5243ede68d0922c1bf3c0dd05986/ltablib.c#L140
--
Cheers,
Vadim