'table.tunpack' using 'aux_getn' like the others

'table.tunpack' was not checking its first argument, which could
result in error messages generated inside the API, without location
information.
This commit is contained in:
Roberto I
2026-03-09 16:24:49 -03:00
parent 36d5d2b284
commit 377cbea61b
2 changed files with 20 additions and 4 deletions

View File

@@ -72,6 +72,19 @@ assert(a==1 and x==nil)
a,x = unpack({1,2}, 1, 1)
assert(a==1 and x==nil)
do -- unpack with non-tables
local debug = require"debug"
local oldmt = debug.getmetatable(0)
local str = "hello"
debug.setmetatable(0,
{ __len = function () return #str end,
__index = function (_, i) return string.sub(str, i, i) end})
assert(table.concat({table.unpack(0)}) == str)
debug.setmetatable(0, oldmt) -- restore original metatable for numbers
end
do
local maxi = (1 << 31) - 1 -- maximum value for an int (usually)
local mini = -(1 << 31) -- minimum value for an int (usually)