# HG changeset patch # User Kim Alvefur # Date 1602258070 -7200 # Node ID 0cfa36fa707ea45beaaaa427c1f87a300ac14175 # Parent 28add4b22a74539edd9d27be06c91175d3752490 util.startup: Include arguments in function string representation Improves usability of the console when digging around the internals. No specific rationale for the function(args) format, it looked best of the variants I tried. diff -r 28add4b22a74 -r 0cfa36fa707e util/startup.lua --- a/util/startup.lua Fri Oct 09 17:34:04 2020 +0200 +++ b/util/startup.lua Fri Oct 09 17:41:10 2020 +0200 @@ -197,8 +197,14 @@ end end function mt.__tostring(f) - local info = debug.getinfo(f, "S"); - return ("function(%s:%d)"):format(info.short_src:match("[^\\/]*$"), info.linedefined); + local info = debug.getinfo(f, "Su"); + for i = 1, info.nparams do + info[i] = debug.getlocal(f, i); + end + if info.isvararg then + info[info.nparams+1] = "..."; + end + return ("function<%s:%d>(%s)"):format(info.short_src:match("[^\\/]*$"), info.linedefined, table.concat(info, ", ")); end debug.setmetatable(function() end, mt); end