From c07d15cf71f962a64aa93cdf29d5fcf592a7548e Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 11 Oct 2020 20:25:32 +0100 Subject: util.startup: Handle missing nparams field from debug info (not present in 5.1) --- util/startup.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/startup.lua b/util/startup.lua index 358c491f..27420c57 100644 --- a/util/startup.lua +++ b/util/startup.lua @@ -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 -- cgit v1.2.3