Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
11151:498b3ab49b9c | 11152:89162d27e1b1 |
---|---|
196 debug.setupvalue(f, i, value); | 196 debug.setupvalue(f, i, value); |
197 end | 197 end |
198 end | 198 end |
199 function mt.__tostring(f) | 199 function mt.__tostring(f) |
200 local info = debug.getinfo(f, "Su"); | 200 local info = debug.getinfo(f, "Su"); |
201 for i = 1, info.nparams do | 201 local n_params = info.nparams or 0; |
202 for i = 1, n_params do | |
202 info[i] = debug.getlocal(f, i); | 203 info[i] = debug.getlocal(f, i); |
203 end | 204 end |
204 if info.isvararg then | 205 if info.isvararg then |
205 info[info.nparams+1] = "..."; | 206 info[n_params+1] = "..."; |
206 end | 207 end |
207 return ("function<%s:%d>(%s)"):format(info.short_src:match("[^\\/]*$"), info.linedefined, table.concat(info, ", ")); | 208 return ("function<%s:%d>(%s)"):format(info.short_src:match("[^\\/]*$"), info.linedefined, table.concat(info, ", ")); |
208 end | 209 end |
209 debug.setmetatable(function() end, mt); | 210 debug.setmetatable(function() end, mt); |
210 end | 211 end |