Software /
code /
prosody
Diff
util/startup.lua @ 11152:89162d27e1b1
util.startup: Handle missing nparams field from debug info (not present in 5.1)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 11 Oct 2020 20:25:32 +0100 |
parent | 11150:0cfa36fa707e |
child | 11304:c022b582d312 |
line wrap: on
line diff
--- a/util/startup.lua Sun Oct 11 14:27:28 2020 +0200 +++ b/util/startup.lua Sun Oct 11 20:25:32 2020 +0100 @@ -198,11 +198,12 @@ 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