From 453d9793fdfd07a2d0706cee1e2fc97c13400880 Mon Sep 17 00:00:00 2001 From: CogentRedTester Date: Sat, 22 Feb 2025 19:08:10 +1030 Subject: [PATCH] address type warnings caused by Lua5.1 and 5.2 changes --- modules/addons.lua | 6 +++--- modules/apis/parse-state.lua | 2 +- modules/utils.lua | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/addons.lua b/modules/addons.lua index fac3731..ea518ac 100644 --- a/modules/addons.lua +++ b/modules/addons.lua @@ -83,14 +83,14 @@ local function run_addon(path) end local chunk, err - if setfenv then + if setfenv then ---@diagnostic disable-line deprecated --since I stupidly named a function loadfile I need to specify the global one --I've been using the name too long to want to change it now chunk, err = _G.loadfile(path) if not chunk then return msg.error(err) end - setfenv(chunk, addon_environment) + setfenv(chunk, addon_environment) ---@diagnostic disable-line deprecated else - chunk, err = _G.loadfile(path, "bt", addon_environment) + chunk, err = _G.loadfile(path, "bt", addon_environment) ---@diagnostic disable-line redundant-parameter if not chunk then return msg.error(err) end end diff --git a/modules/apis/parse-state.lua b/modules/apis/parse-state.lua index ee1bc47..bb61e6e 100644 --- a/modules/apis/parse-state.lua +++ b/modules/apis/parse-state.lua @@ -26,7 +26,7 @@ function parse_state_API:yield(...) msg.verbose("browser no longer waiting for list - aborting parse for", self.directory) error(g.ABORT_ERROR) end - return unpack(result, 1, result.n) + return table.unpack(result, 1, result.n) end ---Checks if the current coroutine is the one handling the browser's request. diff --git a/modules/utils.lua b/modules/utils.lua index d60db82..608328d 100644 --- a/modules/utils.lua +++ b/modules/utils.lua @@ -23,7 +23,7 @@ fb_utils.coroutine = {} --implements table.pack if on lua 5.1 if not table.pack then - table.unpack = unpack + table.unpack = unpack ---@diagnostic disable-line deprecated ---@diagnostic disable-next-line: duplicate-set-field function table.pack(...) local t = {n = select("#", ...), ...} @@ -504,11 +504,11 @@ function fb_utils.evaluate_string(str, chunkname, custom_env, env_defaults) end local chunk, err - if setfenv then - chunk, err = loadstring(str, chunkname) - if chunk then setfenv(chunk, env) end + if setfenv then ---@diagnostic disable-line deprecated + chunk, err = loadstring(str, chunkname) ---@diagnostic disable-line deprecated + if chunk then setfenv(chunk, env) end ---@diagnostic disable-line deprecated else - chunk, err = load(str, chunkname, 't', env) + chunk, err = load(str, chunkname, 't', env) ---@diagnostic disable-line redundant-parameter end if not chunk then msg.warn('failed to load string:', str) @@ -563,7 +563,7 @@ fb_utils.code_fns = { i = function(item, s) local i = fb_utils.list.indexOf(s.list, item) if #s.list == 0 then return 0 end - return ('%0'..math.ceil(math.log10(#s.list))..'d'):format(i ~= -1 and i or 0) + return ('%0'..math.ceil(math.log10(#s.list))..'d'):format(i ~= -1 and i or 0) ---@diagnostic disable-line deprecated end, j = function (item, s) return fb_utils.list.indexOf(s.list, item) ~= -1 and math.abs(fb_utils.list.indexOf( fb_utils.sort_keys(s.selection) , item)) or 0