table.unpack does not produce a line number on error
"'Vadim (vadcx)' via lua-l" <[email protected]>
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
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 -- You received this message because you are subscribed to the Google Groups "lua-l" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/lua-l/7a4bd943-1189-440e-a3a4-684f65c59d0e%40vad.cx.