From c5933e9ed7902f748e561d92b741d09468ba8067 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 9 Oct 2020 17:41:10 +0200 Subject: 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. --- util/startup.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'util/startup.lua') diff --git a/util/startup.lua b/util/startup.lua index af126e8c..358c491f 100644 --- a/util/startup.lua +++ b/util/startup.lua @@ -197,8 +197,14 @@ function startup.set_function_metatable() 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 -- cgit v1.2.3