mirror of
https://github.com/bjc/prosody.git
synced 2025-04-04 05:37:39 +03:00
util.startup: Handle missing nparams field from debug info (not present in 5.1)
This commit is contained in:
parent
bb3948c857
commit
c07d15cf71
1 changed files with 3 additions and 2 deletions
|
@ -198,11 +198,12 @@ function startup.set_function_metatable()
|
|||
end
|
||||
function mt.__tostring(f)
|
||||
local info = debug.getinfo(f, "Su");
|
||||
for i = 1, info.nparams do
|
||||
local n_params = info.nparams or 0;
|
||||
for i = 1, n_params do
|
||||
info[i] = debug.getlocal(f, i);
|
||||
end
|
||||
if info.isvararg then
|
||||
info[info.nparams+1] = "...";
|
||||
info[n_params+1] = "...";
|
||||
end
|
||||
return ("function<%s:%d>(%s)"):format(info.short_src:match("[^\\/]*$"), info.linedefined, table.concat(info, ", "));
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue