Debug information about extra arguments from __call

'debug.getinfo' can return number of extra arguments added to a call by
a chain of __call metavalues. That information is being used to improve
error messages about errors in these extra arguments.
This commit is contained in:
Roberto Ierusalimschy
2024-11-19 14:09:18 -03:00
parent b117bdb344
commit 50c7c915ee
9 changed files with 83 additions and 12 deletions

View File

@@ -204,6 +204,17 @@ do print"testing chains of '__call'"
assert(Res[i][1] == i)
end
assert(Res[N + 1] == "a" and Res[N + 2] == "b" and Res[N + 3] == "c")
local function u (...)
local n = debug.getinfo(1, 't').extraargs
assert(select("#", ...) == n)
return n
end
for i = 0, N do
assert(u() == i)
u = setmetatable({}, {__call = u})
end
end