diff prosodyctl @ 13925:a4c47203a9eb

various: Do not mutate loop variables as they are treated as const in Lua 5.5 Loop variables are treated as <const> in Lua 5.5 and can't be modified without declaring another local. Ref https://github.com/lua/lua/commit/b2f7b3b79f3117885b265575f6c5dbf934757797
author Kim Alvefur <zash@zash.se>
date Fri, 23 Feb 2024 18:44:13 +0100
parents 883d9d0ccd64
children f20b3f0d892b
line wrap: on
line diff
--- a/prosodyctl	Tue Aug 05 22:35:01 2025 +0200
+++ b/prosodyctl	Fri Feb 23 18:44:13 2024 +0100
@@ -461,15 +461,15 @@
 		local version_field = alternate_version_fields[name] or "_VERSION";
 		if type(module) == "table" and rawget(module, version_field)
 			and name ~= "_G" and not name:match("%.") then
-			name = friendly_names[name] or name;
-			if #name > longest_name then
-				longest_name = #name;
+			local friendly_name = friendly_names[name] or name;
+			if #friendly_name > longest_name then
+				longest_name = #friendly_name;
 			end
 			local mod_version = module[version_field];
-			if tostring(mod_version):sub(1, #name+1) == name .. " " then
-				mod_version = mod_version:sub(#name+2);
+			if tostring(mod_version):sub(1, #friendly_name+1) == friendly_name .. " " then
+				mod_version = mod_version:sub(#friendly_name+2);
 			end
-			module_versions[name] = mod_version;
+			module_versions[friendly_name] = mod_version;
 		end
 	end
 	if lunbound then